-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.py
More file actions
90 lines (72 loc) · 3.17 KB
/
main.py
File metadata and controls
90 lines (72 loc) · 3.17 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from firstcalc import FirstCalc
from secondcalc import SecondCalc
from tvtk.pyface.scene_editor import SceneEditor
from mayavi.tools.mlab_scene_model import MlabSceneModel
from mayavi.core.ui.mayavi_scene import MayaviScene
from Common import *
class ApplicationMain(HasTraits):
scene = Instance(MlabSceneModel, ())
firstcalc = Instance(FirstCalc)
secondcalc = Instance(SecondCalc)
display = Instance(Figure)
markercolor = ColorTrait
markerstyle = Enum(['+',',','*','s','p','d','o'])
markersize = Range(0,10,2)
left_panel = Tabbed(Group(VGroup(Item('display', editor=MPLFigureEditor(),show_label=False, resizable=True)),
HGroup(Item(name='markercolor', label="Color", style="custom",springy=True),
Item(name='markerstyle', label="Marker",springy=True),
Item(name='markersize', label="Size",springy=True)), label='Display'),
Item(name='scene',label='Mayavi',editor=SceneEditor(scene_class=MayaviScene)),show_labels=False)
right_panel = Tabbed(Item('firstcalc', style='custom', label='First Tab',show_label=False),
Item('secondcalc', style='custom', label='Second Tab',show_label=False))
view = View(HSplit(left_panel,
right_panel),
width = 1280,
height = 750,
resizable = True,
title="My First Python 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):
# Initialize halos the way we want to.
# Pass a reference of main (e.g. self) downwards
return FirstCalc(self)
def _secondcalc_default(self):
# Initialize halos the way we want to.
# Pass a reference of main (e.g. self) downwards
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()