-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathHeeksObjDlg.py
105 lines (78 loc) · 3.01 KB
/
HeeksObjDlg.py
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from HDialog import HDialog
from HDialog import HControl
from HDialog import control_border
import PictureFrame
import wx
class HeeksObjDlg(HDialog):
def __init__(self, object, title = '', add_picture = True):
HDialog.__init__(self, title)
self.object = object
self.add_picture = add_picture
self.picture = None
sizerMain = wx.BoxSizer(wx.HORIZONTAL)
# add left sizer
self.sizerLeft = wx.BoxSizer(wx.VERTICAL)
sizerMain.Add(self.sizerLeft, 0, wx.ALL, control_border)
# add right sizer
self.sizerRight = wx.BoxSizer(wx.VERTICAL)
sizerMain.Add(self.sizerRight, 0, wx.ALL, control_border)
self.ignore_event_functions = True
self.AddLeftControls()
if self.add_picture:
self.AddPictureControl()
self.AddRightControls()
self.SetFromData()
self.SetSizer( sizerMain )
sizerMain.SetSizeHints( self )
sizerMain.Fit( self )
self.ignore_event_functions = False
self.Bind(wx.EVT_CHILD_FOCUS, self.OnChildFocus)
self.SetPicture()
self.SetDefaultFocus()
def AddLeftControls(self):
pass
def AddRightControls(self):
# add OK and Cancel to right side
self.MakeOkAndCancel(wx.HORIZONTAL).AddToSizer(self.sizerRight)
def SetDefaultFocus(self):
if self.picture:
self.picture.SetFocus()
def GetData(self):
if self.ignore_event_functions:
return
self.ignore_event_functions = True
self.GetDataRaw()
self.ignore_event_functions = False
self.object.WriteDefaultValues()
def SetFromData(self):
self.SetFromDataRaw()
def GetDataRaw(self):
pass
def SetFromDataRaw(self):
pass
def SetPictureByName(self, name):
self.SetPictureByNameAndFolder(name, 'heeksobj')
def SetPictureByNameAndFolder(self, name, folder):
if self.picture:
self.picture.SetPicture(wx.GetApp().cad_dir + '/bitmaps/' + folder + '/' + name + '.png')
def SetPictureByWindow(self, w):
self.SetPictureByName('general')
def SetPicture(self):
w = self.FindFocus()
if self.picture:
self.SetPictureByWindow(w)
def OnChildFocus(self, event):
if self.ignore_event_functions:
return
if event.GetWindow():
self.SetPicture()
event.Skip()
def OnComboOrCheck(self, event):
if self.ignore_event_functions:
return
self.SetPicture()
def AddPictureControl(self):
self.picture = PictureFrame.PictureWindow(self, wx.Size(300, 200))
pictureSizer = wx.BoxSizer(wx.VERTICAL)
pictureSizer.Add(self.picture, 1, wx.GROW)
HControl(wx.ALL, sizer = pictureSizer).AddToSizer(self.sizerRight)