-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
76 lines (61 loc) · 2.35 KB
/
main.py
File metadata and controls
76 lines (61 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Brendan Griffen - January 2019
from firstcalc import FirstCalc
from CommonMPL import *
class ApplicationMain(HasTraits):
firstcalc = Instance(FirstCalc)
display = Instance(Figure)
markerstyle = Enum(['+',',','*','s','p','d','o'])
markersize = Range(0,10,2)
left_panel = Group(Item('display', editor=MPLFigureEditor(),show_label=False, resizable=True),
HGroup(Item(name='markerstyle', label="Marker"),
Item(name='markersize', label="Size")))
right_panel = Tabbed(Item('firstcalc', style='custom', label='First Tab',show_label=False))
view = View(HSplit(left_panel,
right_panel),
width = 1280,
height = 550,
resizable=True,
title="My First Python3 GUI Interface"
)
def _display_default(self):
"""Initialises the display."""
figure = Figure()
ax = figure.add_subplot(111)
ax = figure.axes[0]
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_xlim(0,1)
ax.set_ylim(0,1)
# Set matplotlib canvas colour to be white
rect = figure.patch
rect.set_facecolor('w')
return figure
def _firstcalc_default(self):
return FirstCalc(self)
def _secondcalc_default(self):
return SecondCalc(self)
def _markercolor_changed(self):
ax = self.display.axes[0]
if hasattr(self, 'display_points'):
self.display_points.set_color(self.markercolor)
self.display_points.set_markeredgecolor(self.markercolor)
wx.CallAfter(self.display.canvas.draw)
def _markerstyle_changed(self):
ax = self.display.axes[0]
if hasattr(self, 'display_points'):
self.display_points.set_marker(self.markerstyle)
wx.CallAfter(self.display.canvas.draw)
def _markersize_changed(self):
ax = self.display.axes[0]
if hasattr(self, 'display_points'):
self.display_points.set_markersize(self.markersize)
wx.CallAfter(self.display.canvas.draw)
def __init__(self, **kwargs):
self.markercolor = 'blue'
self.markersize = 2
self.markerstyle = 'o'
if __name__ == '__main__':
app = ApplicationMain()
app.configure_traits()