1 import wx
2
3
5 - def __init__(
6 self,
7 parent,
8 ID,
9 title = "Remove a layer",
10 size = (300, 300),
11 pos = wx.DefaultPosition,
12 style = wx.DEFAULT_DIALOG_STYLE,
13 useMetal = False,
14 model = None
15 ):
16 self.parent = parent
17 self.model = model
18
19 pre = wx.PreDialog()
20 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
21 pre.Create(parent, ID, title, pos, size, style)
22
23 self.PostCreate(pre)
24
25
26 if 'wxMac' in wx.PlatformInfo and useMetal:
27 self.SetExtraStyle(wx.DIALOG_EX_METAL)
28
29 self._mgr = wx.aui.AuiManager(self)
30
31
32 self.Layernum = len( self.model.depth ) -2
33
34 wx.StaticText(self,
35 -1,
36 "Remove layer:",
37 (20, 40)
38 )
39 self.layerChoices = [ ]
40 for i in xrange( self.Layernum ):
41 txt = "Layer(%s): %s" %( str(i+1), model.names[i+1] )
42 self.layerChoices.append( txt )
43
44 self.removeComboBox = wx.ComboBox(choices=self.layerChoices,
45 id=-1,
46 name=u'typeComboBox',
47 parent=self,
48 pos=wx.Point(90, 40),
49 size=wx.Size(160, 20),
50 style= 0,
51 value=u'Flat'
52 )
53
54 self.removeComboBox.SetSelection(0)
55 self.Bind(wx.EVT_COMBOBOX, self.OnRemoveCombobox, self.removeComboBox)
56 self.selection = 0
57
58 self._mgr.Update()
59
60 self.button = wx.Button(self,
61 wx.ID_OK,
62 '',
63 (160, 90)
64 )
65 self.cancelbutton = wx.Button(self,
66 wx.ID_CANCEL,
67 '',
68 (260, 90)
69 )
70 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnClosePage)
71 self.Bind(wx.EVT_CLOSE, self.OnClose)
72
73
74 self._error = 0
75
76
78 ret = []
79 ret.append( self.getLayerNumValue() )
80 ret.append( self._error )
81
82 return ret
83
84
86 s0 = self.removeComboBox.GetValue()
87 s = s0.split("(")[1].strip().split(")")[0].strip()
88 try:
89 ret = int(s)
90 except:
91 self._error = 1
92 ret = 0
93
94 return ret
95
96
99
100
102 self._mgr.UnInit()
103 event.Skip()
104
105
106 - def OnClosePage(self, event):
108
109
111 self.selection = self.removeComboBox.GetSelection()
112 self.removeComboBox.SetLabel( self.layerChoices[self.selection] )
113 self.removeComboBox.SetValue( self.layerChoices[self.selection] )
114
115
116
117 - def OnRemoveComboboxText(self, event):
118 if self.selection < 0:
119 return
120 else:
121 txt = self.removeComboBox.GetValue()
122 self.TypeDepos[self.selection] = txt
123 self.removeComboBox.SetString(self.selection,txt)
124