author | etisserant |
Mon, 03 Dec 2007 11:30:38 +0100 | |
changeset 320 | f82e758840bd |
parent 314 | 68e83c3ffbb5 |
child 327 | b904d9a99e28 |
permissions | -rw-r--r-- |
205 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of CanFestival, a library implementing CanOpen Stack. |
|
5 |
# |
|
6 |
#Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD |
|
7 |
# |
|
8 |
#See COPYING file for copyrights details. |
|
9 |
# |
|
10 |
#This library is free software; you can redistribute it and/or |
|
11 |
#modify it under the terms of the GNU Lesser General Public |
|
12 |
#License as published by the Free Software Foundation; either |
|
13 |
#version 2.1 of the License, or (at your option) any later version. |
|
14 |
# |
|
15 |
#This library is distributed in the hope that it will be useful, |
|
16 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 |
#Lesser General Public License for more details. |
|
19 |
# |
|
20 |
#You should have received a copy of the GNU Lesser General Public |
|
21 |
#License along with this library; if not, write to the Free Software |
|
22 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
||
24 |
import wx |
|
25 |
||
26 |
import os |
|
27 |
||
258 | 28 |
ScriptDirectory = os.path.split(__file__)[0] |
29 |
||
205 | 30 |
#------------------------------------------------------------------------------- |
31 |
# Editing Communication Dialog |
|
32 |
#------------------------------------------------------------------------------- |
|
33 |
||
34 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
35 |
[ID_COMMUNICATIONDIALOG, ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
36 |
ID_COMMUNICATIONDIALOGCURRENTINDEXES, ID_COMMUNICATIONDIALOGSELECT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
37 |
ID_COMMUNICATIONDIALOGUNSELECT, ID_COMMUNICATIONDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
38 |
ID_COMMUNICATIONDIALOGSTATICTEXT2 |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
39 |
] = [wx.NewId() for _init_ctrls in range(7)] |
205 | 40 |
|
41 |
class CommunicationDialog(wx.Dialog): |
|
42 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
43 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
44 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
45 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
46 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
47 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
48 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
49 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
50 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
51 |
parent.AddSizer(self.LeftGridSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
52 |
parent.AddSizer(self.MiddleGridSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
53 |
parent.AddSizer(self.RightGridSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
54 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
55 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
56 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
57 |
parent.AddGrowableCol(2) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
58 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
59 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
60 |
def _init_coll_LeftGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
61 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
62 |
parent.AddWindow(self.PossibleIndexes, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
63 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
64 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
65 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
66 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
67 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
68 |
def _init_coll_MiddleGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
69 |
parent.AddWindow(self.Select, 0, border=0, flag=wx.ALIGN_BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
70 |
parent.AddWindow(self.Unselect, 0, border=0, flag=wx.ALIGN_TOP) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
71 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
72 |
def _init_coll_MiddleGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
73 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
74 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
75 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
76 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
77 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
78 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
79 |
parent.AddWindow(self.CurrentIndexes, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
80 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
81 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
82 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
83 |
parent.AddGrowableRow(1) |
205 | 84 |
|
85 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
86 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
87 |
self.MainSizer = wx.FlexGridSizer(cols=3, hgap=15, rows=1, vgap=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
88 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
89 |
self.MiddleGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=40) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
90 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
91 |
|
205 | 92 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
93 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
94 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
95 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
96 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
97 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
98 |
self._init_coll_MiddleGridSizer_Items(self.MiddleGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
99 |
self._init_coll_MiddleGridSizer_Growables(self.MiddleGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
100 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
101 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
102 |
|
205 | 103 |
self.SetSizer(self.flexGridSizer1) |
104 |
||
105 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
106 |
wx.Dialog.__init__(self, id=ID_COMMUNICATIONDIALOG, |
205 | 107 |
name='CommunicationDialog', parent=prnt, pos=wx.Point(234, 216), |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
108 |
size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
205 | 109 |
title='Edit Communication Profile') |
110 |
self.SetClientSize(wx.Size(726, 437)) |
|
111 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
112 |
self.staticText1 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
113 |
label='Possible Profile Indexes:', name='staticText1', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
114 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
115 |
17), style=0) |
205 | 116 |
|
117 |
self.PossibleIndexes = wx.ListBox(choices=[], |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
118 |
id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
119 |
name='PossibleIndexes', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
120 |
size=wx.Size(0, 0), style=wx.LB_EXTENDED) |
266 | 121 |
self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnPossibleIndexesDClick, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
122 |
id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
123 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
124 |
self.Select = wx.Button(id=ID_COMMUNICATIONDIALOGSELECT, label='>>', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
125 |
name='Select', parent=self, pos=wx.Point(0, 0), |
205 | 126 |
size=wx.Size(32, 32), style=0) |
127 |
self.Select.Bind(wx.EVT_BUTTON, self.OnSelectButton, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
128 |
id=ID_COMMUNICATIONDIALOGSELECT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
129 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
130 |
self.Unselect = wx.Button(id=ID_COMMUNICATIONDIALOGUNSELECT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
131 |
label='<<', name='Unselect', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
132 |
pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) |
205 | 133 |
self.Unselect.Bind(wx.EVT_BUTTON, self.OnUnselectButton, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
134 |
id=ID_COMMUNICATIONDIALOGUNSELECT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
135 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
136 |
self.staticText2 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
137 |
label='Current Profile Indexes:', name='staticText2', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
138 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, |
205 | 139 |
17), style=0) |
140 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
141 |
self.CurrentIndexes = wx.ListBox(choices=[], |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
142 |
id=ID_COMMUNICATIONDIALOGCURRENTINDEXES, name='CurrentIndexes', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
143 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
144 |
style=wx.LB_EXTENDED) |
266 | 145 |
self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnCurrentIndexesDClick, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
146 |
id=ID_COMMUNICATIONDIALOGCURRENTINDEXES) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
147 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
148 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
149 |
|
205 | 150 |
self._init_sizers() |
151 |
||
152 |
def __init__(self, parent): |
|
153 |
self._init_ctrls(parent) |
|
154 |
self.AllList = [] |
|
155 |
self.CurrentList = [] |
|
156 |
self.IndexDictionary = {} |
|
157 |
||
158 |
def SetIndexDictionary(self, dictionary): |
|
159 |
self.IndexDictionary = dictionary |
|
160 |
||
161 |
def SetCurrentList(self, list): |
|
162 |
self.CurrentList = [] |
|
163 |
self.CurrentList.extend(list) |
|
164 |
self.CurrentList.sort() |
|
165 |
||
166 |
def GetCurrentList(self): |
|
167 |
return self.CurrentList |
|
168 |
||
169 |
def RefreshLists(self): |
|
170 |
self.PossibleIndexes.Clear() |
|
171 |
self.CurrentIndexes.Clear() |
|
172 |
self.AllList = [] |
|
173 |
for index in self.IndexDictionary.iterkeys(): |
|
174 |
if index not in self.CurrentList: |
|
175 |
self.AllList.append(index) |
|
176 |
self.AllList.sort() |
|
177 |
for index in self.AllList: |
|
178 |
self.PossibleIndexes.Append("0x%04X %s"%(index, self.IndexDictionary[index][0])) |
|
179 |
for index in self.CurrentList: |
|
180 |
if index in self.IndexDictionary: |
|
181 |
self.CurrentIndexes.Append("0x%04X %s"%(index, self.IndexDictionary[index][0])) |
|
182 |
||
183 |
def OnPossibleIndexesDClick(self, event): |
|
184 |
self.SelectPossible() |
|
185 |
event.Skip() |
|
186 |
||
187 |
def OnCurrentIndexesDClick(self, event): |
|
188 |
self.UnselectCurrent() |
|
189 |
event.Skip() |
|
190 |
||
191 |
def OnSelectButton(self, event): |
|
192 |
self.SelectPossible() |
|
193 |
event.Skip() |
|
194 |
||
195 |
def OnUnselectButton(self, event): |
|
196 |
self.UnselectCurrent() |
|
197 |
event.Skip() |
|
198 |
||
199 |
def SelectPossible(self): |
|
200 |
selected = self.PossibleIndexes.GetSelections() |
|
201 |
for i in selected: |
|
202 |
self.CurrentList.append(self.AllList[i]) |
|
203 |
self.CurrentList.sort() |
|
204 |
self.RefreshLists() |
|
205 |
||
206 |
def UnselectCurrent(self): |
|
207 |
selected = self.CurrentIndexes.GetSelections() |
|
208 |
for i in selected: |
|
209 |
if not self.IndexDictionary[self.CurrentList[i]][1]: |
|
210 |
self.CurrentList.pop(i) |
|
211 |
self.CurrentList.sort() |
|
212 |
self.RefreshLists() |
|
213 |
||
214 |
||
215 |
||
216 |
#------------------------------------------------------------------------------- |
|
217 |
# Create Map Variable Dialog |
|
218 |
#------------------------------------------------------------------------------- |
|
219 |
||
220 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
221 |
[ID_MAPVARIABLEDIALOG, ID_MAPVARIABLEDIALOGINDEX, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
222 |
ID_MAPVARIABLEDIALOGINDEXNAME, ID_MAPVARIABLEDIALOGSPACER, |
259 | 223 |
ID_MAPVARIABLEDIALOGSPACER2, ID_MAPVARIABLEDIALOGNUMBER, |
224 |
ID_MAPVARIABLEDIALOGRADIOBUTTON1, ID_MAPVARIABLEDIALOGRADIOBUTTON2, |
|
225 |
ID_MAPVARIABLEDIALOGRADIOBUTTON3, ID_MAPVARIABLEDIALOGSTATICTEXT1, |
|
226 |
ID_MAPVARIABLEDIALOGSTATICTEXT2, ID_MAPVARIABLEDIALOGSTATICTEXT3, |
|
227 |
ID_MAPVARIABLEDIALOGSTATICTEXT4, |
|
228 |
] = [wx.NewId() for _init_ctrls in range(13)] |
|
205 | 229 |
|
230 |
class MapVariableDialog(wx.Dialog): |
|
231 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
232 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
233 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
234 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
235 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
236 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
237 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
238 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
239 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
240 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
241 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
242 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
243 |
parent.AddWindow(self.Index, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
244 |
parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) |
259 | 245 |
parent.AddWindow(self.Spacer2, 0, border=0, flag=wx.GROW) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
246 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
247 |
parent.AddWindow(self.radioButton2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
248 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
249 |
parent.AddWindow(self.IndexName, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
250 |
parent.AddWindow(self.radioButton3, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
251 |
parent.AddWindow(self.Number, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
252 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
253 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
254 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
255 |
parent.AddGrowableCol(2) |
205 | 256 |
|
257 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
258 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
259 |
self.MainSizer = wx.FlexGridSizer(cols=3, hgap=30, rows=4, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
260 |
|
205 | 261 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
262 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
263 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
264 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
265 |
|
205 | 266 |
self.SetSizer(self.flexGridSizer1) |
267 |
||
268 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
269 |
wx.Dialog.__init__(self, id=ID_MAPVARIABLEDIALOG, |
205 | 270 |
name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223), |
271 |
size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE, |
|
272 |
title='Add Map Variable') |
|
273 |
self.SetClientSize(wx.Size(444, 186)) |
|
274 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
275 |
self.staticText1 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
276 |
label='Index:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
277 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
278 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
279 |
self.staticText2 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
280 |
label='Type:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
281 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
282 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
283 |
self.staticText3 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
284 |
label='Name:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
285 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
286 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
287 |
self.staticText4 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
288 |
label='Number:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
289 |
pos=wx.Point(0, 0), size=wx.Size(0, 16), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
290 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
291 |
self.radioButton1 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
292 |
label='VAR', name='radioButton1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
293 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_GROUP) |
205 | 294 |
self.radioButton1.SetValue(True) |
295 |
self.radioButton1.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton1Click, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
296 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
297 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
298 |
self.radioButton2 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
299 |
label='ARRAY', name='radioButton2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
300 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE) |
205 | 301 |
self.radioButton2.SetValue(False) |
302 |
self.radioButton2.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton2Click, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
303 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON2) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
304 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
305 |
self.radioButton3 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
306 |
label='REC', name='radioButton3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
307 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE) |
205 | 308 |
self.radioButton3.SetValue(False) |
309 |
self.radioButton3.Bind(wx.EVT_RADIOBUTTON, self.OnRadioButton3Click, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
310 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON3) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
311 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
312 |
self.Index = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGINDEX, name='Index', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
313 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
314 |
style=0, value='0x2000') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
315 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
316 |
self.IndexName = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGINDEXNAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
317 |
name='IndexName', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
318 |
size=wx.Size(0, 24), style=0, value='Undefined') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
319 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
320 |
self.Number = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGNUMBER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
321 |
name='Number', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
322 |
size=wx.Size(0, 24), style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
323 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
324 |
self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
325 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
326 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
327 |
|
259 | 328 |
self.Spacer2 = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER2, |
329 |
name='Spacer2', parent=self, pos=wx.Point(0, 0), |
|
330 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
331 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
332 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
333 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
334 |
|
205 | 335 |
self._init_sizers() |
336 |
||
337 |
def __init__(self, parent): |
|
338 |
self._init_ctrls(parent) |
|
339 |
self.staticText4.Enable(False) |
|
340 |
self.Number.Enable(False) |
|
341 |
||
342 |
def SetIndex(self, index): |
|
343 |
self.Index.SetValue("0x%04X"%index) |
|
344 |
||
345 |
def OnOK(self, event): |
|
346 |
error = [] |
|
347 |
try: |
|
348 |
int(self.Index.GetValue(), 16) |
|
349 |
except: |
|
350 |
error.append("Index") |
|
351 |
if self.radioButton2.GetValue() or self.radioButton3.GetValue(): |
|
352 |
try: |
|
353 |
int(self.Number.GetValue()) |
|
354 |
except: |
|
355 |
error.append("Number") |
|
356 |
if len(error) > 0: |
|
357 |
text = "" |
|
358 |
if len(error) > 1: |
|
359 |
suffix = "s" |
|
360 |
else: |
|
361 |
suffix = "" |
|
362 |
for i, item in enumerate(error): |
|
363 |
if i == 0: |
|
364 |
text += item |
|
365 |
elif i == len(error) - 1: |
|
366 |
text += " and %s"%item |
|
367 |
else: |
|
368 |
text += ", %s"%item |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
369 |
message = wx.MessageDialog(self, "Form isn't valid. %s must be integer%s!"%(text,suffix), "Error", wx.OK|wx.ICON_ERROR) |
205 | 370 |
message.ShowModal() |
371 |
message.Destroy() |
|
372 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
373 |
self.EndModal(wx.ID_OK) |
205 | 374 |
|
375 |
def GetValues(self): |
|
376 |
name = self.IndexName.GetValue() |
|
377 |
index = int(self.Index.GetValue(), 16) |
|
378 |
if self.radioButton1.GetValue(): |
|
379 |
struct = 1 |
|
380 |
number = None |
|
381 |
elif self.radioButton2.GetValue(): |
|
382 |
struct = 3 |
|
383 |
number = int(self.Number.GetValue()) |
|
384 |
elif self.radioButton3.GetValue(): |
|
385 |
struct = 7 |
|
386 |
number = int(self.Number.GetValue()) |
|
387 |
return index, name, struct, number |
|
388 |
||
389 |
def OnRadioButton1Click(self, event): |
|
390 |
self.EnableNumberTyping(False) |
|
391 |
event.Skip() |
|
392 |
||
393 |
def OnRadioButton2Click(self, event): |
|
394 |
self.EnableNumberTyping(True) |
|
395 |
event.Skip() |
|
396 |
||
397 |
def OnRadioButton3Click(self, event): |
|
398 |
self.EnableNumberTyping(True) |
|
399 |
event.Skip() |
|
400 |
||
401 |
def EnableNumberTyping(self, enable): |
|
402 |
self.staticText4.Enable(enable) |
|
403 |
self.Number.Enable(enable) |
|
404 |
||
405 |
||
406 |
#------------------------------------------------------------------------------- |
|
407 |
# Create User Type Dialog |
|
408 |
#------------------------------------------------------------------------------- |
|
409 |
||
410 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
411 |
[ID_USERTYPEDIALOG, ID_USERTYPEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
412 |
ID_USERTYPEDIALOGTYPE, ID_USERTYPEDIALOGMAX, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
413 |
ID_USERTYPEDIALOGMIN, ID_USERTYPEDIALOGLENGTH, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
414 |
ID_USERTYPEDIALOGSTATICBOX1, ID_USERTYPEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
415 |
ID_USERTYPEDIALOGSTATICTEXT2, ID_USERTYPEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
416 |
ID_USERTYPEDIALOGSTATICTEXT4, |
205 | 417 |
] = [wx.NewId() for _init_ctrls in range(11)] |
418 |
||
419 |
class UserTypeDialog(wx.Dialog): |
|
420 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
421 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
422 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
423 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
424 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
425 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
426 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
427 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
428 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
429 |
parent.AddSizer(self.LeftGridSizer, 2, border=5, flag=wx.GROW|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
430 |
parent.AddSizer(self.RightBoxSizer, 3, border=5, flag=wx.GROW|wx.LEFT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
431 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
432 |
def _init_coll_LeftGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
433 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
434 |
parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
435 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
436 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
437 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
438 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
439 |
parent.AddGrowableRow(2) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
440 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
441 |
def _init_coll_RightBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
442 |
parent.AddSizer(self.RightBoxGridSizer, 0, border=10, flag=wx.GROW|wx.ALL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
443 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
444 |
def _init_coll_RightBoxGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
445 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
446 |
parent.AddWindow(self.Min, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
447 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
448 |
parent.AddWindow(self.Max, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
449 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
450 |
parent.AddWindow(self.Length, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
451 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
452 |
def _init_coll_RightBoxGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
453 |
parent.AddGrowableCol(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
454 |
|
205 | 455 |
def _init_sizers(self): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
456 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
457 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
458 |
self.LeftGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
459 |
self.RightBoxSizer = wx.StaticBoxSizer(self.staticBox1, wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
460 |
self.RightBoxGridSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
461 |
|
205 | 462 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
463 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
464 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
465 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
466 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
467 |
self._init_coll_RightBoxSizer_Items(self.RightBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
468 |
self._init_coll_RightBoxGridSizer_Items(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
469 |
self._init_coll_RightBoxGridSizer_Growables(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
470 |
|
205 | 471 |
self.SetSizer(self.flexGridSizer1) |
472 |
||
473 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
474 |
wx.Dialog.__init__(self, id=ID_USERTYPEDIALOG, name='UserTypeDialog', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
475 |
parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210), |
205 | 476 |
style=wx.DEFAULT_DIALOG_STYLE, title='Add User Type') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
477 |
self.SetClientSize(wx.Size(444, 210)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
478 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
479 |
self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
480 |
label='Type:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
481 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
482 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
483 |
self.Type = wx.Choice(choices=[], id=ID_USERTYPEDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
484 |
name='Type', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
485 |
size=wx.Size(0, 24), style=0) |
205 | 486 |
self.Type.Bind(wx.EVT_CHOICE, self.OnTypeChoice, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
487 |
id=ID_USERTYPEDIALOGTYPE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
488 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
489 |
self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
490 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
491 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
492 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
493 |
self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
494 |
label='Values', name='staticBox1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
495 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
496 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
497 |
self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
498 |
label='Minimum:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
499 |
pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
500 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
501 |
self.Min = wx.TextCtrl(id=ID_USERTYPEDIALOGMIN, name='Min', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
502 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
503 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
504 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
505 |
self.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
506 |
label='Maximum:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
507 |
pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
508 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
509 |
self.Max = wx.TextCtrl(id=ID_USERTYPEDIALOGMAX, name='Max', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
510 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
511 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
512 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
513 |
self.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
514 |
label='Length:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
515 |
pos=wx.Point(0, 0), size=wx.Size(80, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
516 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
517 |
self.Length = wx.TextCtrl(id=ID_USERTYPEDIALOGLENGTH, name='Length', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
518 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
519 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
520 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
521 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
522 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
523 |
|
205 | 524 |
self._init_sizers() |
525 |
||
526 |
def __init__(self, parent): |
|
527 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
528 |
|
205 | 529 |
self.TypeDictionary = {} |
530 |
||
531 |
def OnOK(self, event): |
|
532 |
error = [] |
|
533 |
good = True |
|
534 |
firstmessage = "" |
|
535 |
secondmessage = "" |
|
536 |
name = self.Type.GetStringSelection() |
|
537 |
if name != "": |
|
538 |
valuetype = self.TypeDictionary[name][1] |
|
539 |
if valuetype == 0: |
|
540 |
try: |
|
541 |
int(self.Min.GetValue(), 16) |
|
542 |
except: |
|
543 |
error.append("Minimum") |
|
544 |
good = False |
|
545 |
try: |
|
546 |
int(self.Max.GetValue(), 16) |
|
547 |
except: |
|
548 |
error.append("Maximum") |
|
549 |
good = False |
|
550 |
elif valuetype == 1: |
|
551 |
try: |
|
552 |
int(self.Length.GetValue(), 16) |
|
553 |
except: |
|
554 |
error.append("Length") |
|
555 |
good = False |
|
556 |
if len(error) > 0: |
|
557 |
secondmessage = ". " |
|
558 |
for i, item in enumerate(error): |
|
559 |
if i == 0: |
|
560 |
secondmessage += item |
|
561 |
elif i == len(error) - 1: |
|
562 |
secondmessage += " and %s"%item |
|
563 |
else: |
|
564 |
secondmessage += ", %s"%item |
|
565 |
secondmessage += " must be integer" |
|
566 |
if len(error) > 1: |
|
567 |
secondmessage += "s" |
|
568 |
else: |
|
569 |
firstmessage = ". A type must be selected" |
|
570 |
good = False |
|
571 |
if not good: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
572 |
message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR) |
205 | 573 |
message.ShowModal() |
574 |
message.Destroy() |
|
575 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
576 |
self.EndModal(wx.ID_OK) |
205 | 577 |
|
578 |
def SetValues(self, min = None, max = None, length = None): |
|
579 |
if min != None: |
|
580 |
self.Min.SetValue(str(min)) |
|
581 |
if max != None: |
|
582 |
self.Max.SetValue(str(max)) |
|
583 |
if length != None: |
|
584 |
self.Length.SetValue(str(length)) |
|
585 |
||
586 |
def SetTypeList(self, typedic, type = None): |
|
587 |
self.Type.Clear() |
|
588 |
list = [] |
|
589 |
for index, (name, valuetype) in typedic.iteritems(): |
|
590 |
self.TypeDictionary[name] = (index, valuetype) |
|
591 |
list.append((index, name)) |
|
592 |
list.sort() |
|
593 |
for index, name in list: |
|
594 |
self.Type.Append(name) |
|
595 |
if type != None: |
|
596 |
self.Type.SetStringSelection(typedic[type][0]) |
|
597 |
self.RefreshValues() |
|
598 |
||
599 |
def OnTypeChoice(self, event): |
|
600 |
self.RefreshValues() |
|
601 |
event.Skip() |
|
602 |
||
603 |
def RefreshValues(self): |
|
604 |
name = self.Type.GetStringSelection() |
|
605 |
if name != "": |
|
606 |
valuetype = self.TypeDictionary[name][1] |
|
607 |
if valuetype == 0: |
|
608 |
self.staticText2.Enable(True) |
|
609 |
self.staticText3.Enable(True) |
|
610 |
self.staticText4.Enable(False) |
|
611 |
self.Min.Enable(True) |
|
612 |
self.Max.Enable(True) |
|
613 |
self.Length.Enable(False) |
|
614 |
elif valuetype == 1: |
|
615 |
self.staticText2.Enable(False) |
|
616 |
self.staticText3.Enable(False) |
|
617 |
self.staticText4.Enable(True) |
|
618 |
self.Min.Enable(False) |
|
619 |
self.Max.Enable(False) |
|
620 |
self.Length.Enable(True) |
|
621 |
else: |
|
622 |
self.staticText2.Enable(False) |
|
623 |
self.staticText3.Enable(False) |
|
624 |
self.staticText4.Enable(False) |
|
625 |
self.Min.Enable(False) |
|
626 |
self.Max.Enable(False) |
|
627 |
self.Length.Enable(False) |
|
628 |
||
629 |
def GetValues(self): |
|
630 |
name = self.Type.GetStringSelection() |
|
631 |
type = self.TypeDictionary[name][0] |
|
632 |
min = int(self.Min.GetValue()) |
|
633 |
max = int(self.Max.GetValue()) |
|
634 |
length = int(self.Length.GetValue()) |
|
635 |
return type, min, max, length |
|
636 |
||
637 |
||
638 |
||
639 |
#------------------------------------------------------------------------------- |
|
640 |
# Editing Node Infos Dialog |
|
641 |
#------------------------------------------------------------------------------- |
|
642 |
||
643 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
644 |
[ID_NODEINFOSDIALOG, ID_NODEINFOSDIALOGNAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
645 |
ID_NODEINFOSDIALOGNODEID, ID_NODEINFOSDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
646 |
ID_NODEINFOSDIALOGTYPE, ID_NODEINFOSDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
647 |
ID_NODEINFOSDIALOGSTATICTEXT2, ID_NODEINFOSDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
648 |
ID_NODEINFOSDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
649 |
] = [wx.NewId() for _init_ctrls in range(9)] |
205 | 650 |
|
651 |
class NodeInfosDialog(wx.Dialog): |
|
652 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
653 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
654 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
655 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
656 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
657 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
658 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
659 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
660 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
661 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
276 | 662 |
parent.AddWindow(self.NodeName, 0, border=0, flag=wx.GROW) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
663 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
664 |
parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
665 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
666 |
parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
667 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
668 |
parent.AddWindow(self.Description, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
669 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
670 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
671 |
parent.AddGrowableCol(0) |
205 | 672 |
|
673 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
674 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
675 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=8, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
676 |
|
205 | 677 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
678 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
679 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
680 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
681 |
|
205 | 682 |
self.SetSizer(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
683 |
|
205 | 684 |
def _init_ctrls(self, prnt): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
685 |
wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG, |
205 | 686 |
name='NodeInfosDialog', parent=prnt, pos=wx.Point(376, 223), |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
687 |
size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE, |
205 | 688 |
title='Node Infos') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
689 |
self.SetClientSize(wx.Size(300, 280)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
690 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
691 |
self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
692 |
label='Name:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
693 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
694 |
|
276 | 695 |
self.NodeName = wx.TextCtrl(id=ID_NODEINFOSDIALOGNAME, name='NodeName', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
696 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
697 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
698 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
699 |
self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
700 |
label='Node ID:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
701 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
702 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
703 |
self.NodeID = wx.TextCtrl(id=ID_NODEINFOSDIALOGNODEID, name='NodeID', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
704 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 25), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
705 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
706 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
707 |
self.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
708 |
label='Type:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
709 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
710 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
711 |
self.Type = wx.Choice(choices=[], id=ID_NODEINFOSDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
712 |
name='Type', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
713 |
size=wx.Size(0, 25), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
714 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
715 |
self.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
716 |
label='Description:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
717 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
718 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
719 |
self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
720 |
name='Description', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
721 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
722 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
723 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
724 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
725 |
|
205 | 726 |
self._init_sizers() |
727 |
||
728 |
def __init__(self, parent): |
|
729 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
730 |
|
299 | 731 |
self.staticText2.Hide() |
732 |
self.NodeID.Hide() |
|
733 |
||
205 | 734 |
self.Type.Append("master") |
735 |
self.Type.Append("slave") |
|
736 |
||
737 |
def OnOK(self, event): |
|
276 | 738 |
name = self.NodeName.GetValue() |
205 | 739 |
message = "" |
740 |
if name != "": |
|
741 |
good = not name[0].isdigit() |
|
742 |
for item in name.split("_"): |
|
743 |
good &= item.isalnum() |
|
744 |
if not good: |
|
745 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
746 |
if message != "": |
|
747 |
try: |
|
748 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
749 |
except: |
|
750 |
message = "Node ID must be integer!" |
|
751 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
752 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 753 |
message.ShowModal() |
754 |
message.Destroy() |
|
276 | 755 |
self.NodeName.SetFocus() |
205 | 756 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
757 |
self.EndModal(wx.ID_OK) |
205 | 758 |
|
759 |
def SetValues(self, name, id, type, description): |
|
276 | 760 |
self.NodeName.SetValue(name) |
205 | 761 |
self.NodeID.SetValue("0x%02X"%id) |
762 |
self.Type.SetStringSelection(type) |
|
763 |
self.Description.SetValue(description) |
|
764 |
||
765 |
def GetValues(self): |
|
276 | 766 |
name = self.NodeName.GetValue() |
205 | 767 |
nodeid = int(self.NodeID.GetValue(), 16) |
768 |
type = self.Type.GetStringSelection() |
|
769 |
description = self.Description.GetValue() |
|
770 |
return name, nodeid, type, description |
|
771 |
||
772 |
||
773 |
||
774 |
#------------------------------------------------------------------------------- |
|
775 |
# Create New Node Dialog |
|
776 |
#------------------------------------------------------------------------------- |
|
777 |
||
778 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
779 |
[ID_CREATENODEDIALOG, ID_CREATENODEDIALOGEMERGENCY, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
780 |
ID_CREATENODEDIALOGGENSYNC, ID_CREATENODEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
781 |
ID_CREATENODEDIALOGNAME, ID_CREATENODEDIALOGNMT_HEARTBEAT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
782 |
ID_CREATENODEDIALOGNMT_NODEGUARDING, ID_CREATENODEDIALOGNMT_NONE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
783 |
ID_CREATENODEDIALOGNODEID, ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
784 |
ID_CREATENODEDIALOGSAVECONFIG, ID_CREATENODEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
785 |
ID_CREATENODEDIALOGSTATICTEXT2, ID_CREATENODEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
786 |
ID_CREATENODEDIALOGSTATICTEXT4, ID_CREATENODEDIALOGSTATICTEXT5, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
787 |
ID_CREATENODEDIALOGSTATICTEXT6, ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
788 |
ID_CREATENODEDIALOGSTOREEDS, ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
789 |
ID_CREATENODEDIALOGTYPE, |
205 | 790 |
] = [wx.NewId() for _init_ctrls in range(21)] |
791 |
||
792 |
class CreateNodeDialog(wx.Dialog): |
|
793 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
794 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
795 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
796 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
797 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
798 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
799 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
800 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
801 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
802 |
parent.AddSizer(self.TopBoxSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
803 |
parent.AddWindow(self.staticText7, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
804 |
parent.AddWindow(self.Description, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
805 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
806 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
807 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
808 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
809 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
810 |
def _init_coll_TopBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
811 |
parent.AddSizer(self.LeftBoxSizer, 1, border=10, flag=wx.GROW|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
812 |
parent.AddSizer(self.RightGridSizer, 1, border=10, flag=wx.GROW|wx.LEFT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
813 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
814 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
815 |
parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
816 |
parent.AddWindow(self.Type, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
817 |
parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
276 | 818 |
parent.AddWindow(self.NodeName, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
819 |
parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
820 |
parent.AddWindow(self.NodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
821 |
parent.AddWindow(self.staticText4, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
822 |
parent.AddWindow(self.Profile, 0, border=20, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
823 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
824 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
825 |
parent.AddSizer(self.RightTopGridSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
826 |
parent.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
827 |
parent.AddSizer(self.RightBottomGridSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
828 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
829 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
830 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
831 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
832 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
833 |
def _init_coll_RightTopGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
834 |
parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
835 |
parent.AddWindow(self.NMT_None, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
836 |
parent.AddWindow(self.NMT_NodeGuarding, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
837 |
parent.AddWindow(self.NMT_Heartbeat, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
838 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
839 |
def _init_coll_RightTopGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
840 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
841 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
842 |
def _init_coll_RightBottomGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
843 |
parent.AddWindow(self.staticText6, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
844 |
parent.AddWindow(self.DS302, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
845 |
parent.AddWindow(self.GenSYNC, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
846 |
parent.AddWindow(self.Emergency, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
847 |
parent.AddWindow(self.SaveConfig, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
848 |
parent.AddWindow(self.StoreEDS, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
849 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
850 |
def _init_coll_RightBottomGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
851 |
parent.AddGrowableCol(0) |
205 | 852 |
|
853 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
854 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
855 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=5, rows=3, vgap=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
856 |
self.TopBoxSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
857 |
self.LeftBoxSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
858 |
self.RightGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=5) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
859 |
self.RightTopGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=4, vgap=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
860 |
self.RightBottomGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=6, vgap=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
861 |
|
205 | 862 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
863 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
864 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
865 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
866 |
self._init_coll_TopBoxSizer_Items(self.TopBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
867 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
868 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
869 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
870 |
self._init_coll_RightTopGridSizer_Items(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
871 |
self._init_coll_RightTopGridSizer_Growables(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
872 |
self._init_coll_RightBottomGridSizer_Items(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
873 |
self._init_coll_RightBottomGridSizer_Growables(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
874 |
|
205 | 875 |
self.SetSizer(self.flexGridSizer1) |
876 |
||
877 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
878 |
wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
205 | 879 |
name='CreateNodeDialog', parent=prnt, pos=wx.Point(376, 223), |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
880 |
size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
205 | 881 |
title='Create a new Node') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
882 |
self.SetClientSize(wx.Size(450, 350)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
883 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
884 |
self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
259 | 885 |
label='Type:', name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
886 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
887 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
888 |
self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
259 | 889 |
label='Name:', name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
890 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
891 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
892 |
self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
259 | 893 |
label='Node ID:', name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
894 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
895 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
896 |
self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
897 |
label='Profile:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
898 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
899 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
900 |
self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
901 |
name='Type', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
902 |
size=wx.Size(0, 25), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
903 |
|
276 | 904 |
self.NodeName = wx.TextCtrl(id=ID_CREATENODEDIALOGNAME, name='NodeName', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
905 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
906 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
907 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
908 |
self.NodeID = wx.TextCtrl(id=ID_CREATENODEDIALOGNODEID, name='NodeID', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
909 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
910 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
911 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
912 |
self.Profile = wx.Choice(choices=[], id=ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
913 |
name='Profile', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
914 |
size=wx.Size(0, 24), style=0) |
205 | 915 |
self.Profile.Bind(wx.EVT_CHOICE, self.OnProfileChoice, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
916 |
id=ID_CREATENODEDIALOGPROFILE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
917 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
918 |
self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
205 | 919 |
label='Network Management:', name='staticText5', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
920 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
921 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
922 |
self.NMT_None = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NONE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
923 |
label='None', name='NMT_None', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
924 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 925 |
self.NMT_None.SetValue(True) |
926 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
927 |
self.NMT_NodeGuarding = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NODEGUARDING, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
928 |
label='Node Guarding', name='NMT_NodeGuarding', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
929 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 930 |
self.NMT_NodeGuarding.SetValue(False) |
931 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
932 |
self.NMT_Heartbeat = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_HEARTBEAT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
933 |
label='Heartbeat', name='NMT_Heartbeat', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
934 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 935 |
self.NMT_Heartbeat.SetValue(False) |
936 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
937 |
self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
938 |
label='Options:', name='staticText6', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
939 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
940 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
941 |
self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
942 |
label='DS-302 Profile', name='DS302', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
943 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 944 |
self.DS302.SetValue(False) |
945 |
#self.DS302.Enable(False) |
|
946 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
947 |
self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
948 |
label='Generate SYNC', name='GenSYNC', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
949 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 950 |
self.GenSYNC.SetValue(False) |
951 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
952 |
self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
205 | 953 |
label='Emergency support', name='Emergency', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
954 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 955 |
self.Emergency.SetValue(False) |
956 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
957 |
self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
958 |
label='Save Configuration', name='SaveConfig', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
959 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 960 |
self.SaveConfig.SetValue(False) |
961 |
self.SaveConfig.Enable(False) |
|
962 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
963 |
self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
964 |
label='Store EDS', name='StoreEDS', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
965 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
966 |
self.StoreEDS.SetValue(False) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
967 |
self.StoreEDS.Hide() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
968 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
969 |
self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
970 |
label='Description:', name='staticText7', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
971 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
972 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
973 |
self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
974 |
name='Description', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
975 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
976 |
|
259 | 977 |
self.Spacer = wx.Panel(id=ID_CREATENODEDIALOGSPACER, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
978 |
name='Spacer', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
979 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
980 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
981 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
982 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
983 |
|
205 | 984 |
self._init_sizers() |
985 |
||
258 | 986 |
def __init__(self, parent): |
205 | 987 |
self._init_ctrls(parent) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
988 |
|
299 | 989 |
self.staticText3.Hide() |
990 |
self.NodeID.Hide() |
|
991 |
||
205 | 992 |
self.NodeID.SetValue("0x00") |
993 |
self.Type.Append("master") |
|
994 |
self.Type.Append("slave") |
|
995 |
self.Type.SetStringSelection("slave") |
|
996 |
self.Description.SetValue("") |
|
997 |
self.ListProfile = {"None" : ""} |
|
998 |
self.Profile.Append("None") |
|
258 | 999 |
self.Directory = os.path.join(ScriptDirectory, "config") |
205 | 1000 |
listfiles = os.listdir(self.Directory) |
1001 |
listfiles.sort() |
|
1002 |
for item in listfiles: |
|
1003 |
name, extend = os.path.splitext(item) |
|
1004 |
if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
|
1005 |
self.ListProfile[name] = os.path.join(self.Directory, item) |
|
1006 |
self.Profile.Append(name) |
|
1007 |
self.Profile.Append("Other") |
|
1008 |
self.Profile.SetStringSelection("None") |
|
276 | 1009 |
self.NodeName.SetFocus() |
205 | 1010 |
|
1011 |
def OnOK(self, event): |
|
276 | 1012 |
name = self.NodeName.GetValue() |
205 | 1013 |
message = "" |
1014 |
if name != "": |
|
1015 |
good = not name[0].isdigit() |
|
1016 |
for item in name.split("_"): |
|
1017 |
good &= item.isalnum() |
|
1018 |
if not good: |
|
1019 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
1020 |
if message != "": |
|
1021 |
try: |
|
1022 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1023 |
except: |
|
1024 |
message = "Node ID must be an integer!" |
|
1025 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1026 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 1027 |
message.ShowModal() |
1028 |
message.Destroy() |
|
276 | 1029 |
self.NodeName.SetFocus() |
205 | 1030 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1031 |
self.EndModal(wx.ID_OK) |
205 | 1032 |
|
1033 |
def GetValues(self): |
|
276 | 1034 |
name = self.NodeName.GetValue() |
205 | 1035 |
nodeid = 0 |
1036 |
if self.NodeID.GetValue() != "": |
|
1037 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1038 |
type = self.Type.GetStringSelection() |
|
1039 |
description = self.Description.GetValue() |
|
1040 |
return name, nodeid, type, description |
|
1041 |
||
1042 |
def GetProfile(self): |
|
1043 |
name = self.Profile.GetStringSelection() |
|
1044 |
return name, self.ListProfile[name] |
|
1045 |
||
1046 |
def GetNMTManagement(self): |
|
1047 |
if self.NMT_None.GetValue(): |
|
1048 |
return "None" |
|
1049 |
elif self.NMT_NodeGuarding.GetValue(): |
|
1050 |
return "NodeGuarding" |
|
1051 |
elif self.NMT_Heartbeat.GetValue(): |
|
1052 |
return "Heartbeat" |
|
1053 |
return None |
|
1054 |
||
1055 |
def GetOptions(self): |
|
1056 |
options = [] |
|
1057 |
if self.DS302.GetValue(): |
|
1058 |
options.append("DS302") |
|
1059 |
if self.GenSYNC.GetValue(): |
|
1060 |
options.append("GenSYNC") |
|
1061 |
if self.Emergency.GetValue(): |
|
1062 |
options.append("Emergency") |
|
1063 |
if self.SaveConfig.GetValue(): |
|
1064 |
options.append("SaveConfig") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1065 |
if self.StoreEDS.GetValue(): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1066 |
options.append("StoreEDS") |
205 | 1067 |
return options |
1068 |
||
1069 |
def OnProfileChoice(self, event): |
|
1070 |
if self.Profile.GetStringSelection() == "Other": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1071 |
dialog = wx.FileDialog(self, "Choose a file", self.Directory, "", "OD Profile files (*.prf)|*.prf|All files|*.*", wx.OPEN|wx.CHANGE_DIR) |
205 | 1072 |
dialog.ShowModal() |
1073 |
filepath = dialog.GetPath() |
|
1074 |
dialog.Destroy() |
|
1075 |
if os.path.isfile(filepath): |
|
1076 |
name = os.path.splitext(os.path.basename(filepath))[0] |
|
1077 |
self.ListProfile[name] = filepath |
|
1078 |
length = self.Profile.GetCount() |
|
1079 |
self.Profile.Insert(name, length - 2) |
|
1080 |
self.Profile.SetStringSelection(name) |
|
1081 |
else: |
|
1082 |
self.Profile.SetStringSelection("None") |
|
1083 |
event.Skip() |
|
1084 |
||
1085 |
||
1086 |
#------------------------------------------------------------------------------- |
|
1087 |
# ADD Slave to NodeList Dialog |
|
1088 |
#------------------------------------------------------------------------------- |
|
1089 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1090 |
[ID_ADDSLAVEDIALOG, ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1091 |
ID_ADDSLAVEDIALOGSLAVENODEID, ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1092 |
ID_ADDSLAVEDIALOGIMPORTEDS, ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1093 |
ID_ADDSLAVEDIALOGSTATICTEXT2, ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1094 |
] = [wx.NewId() for _init_ctrls in range(8)] |
205 | 1095 |
|
1096 |
class AddSlaveDialog(wx.Dialog): |
|
1097 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1098 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1099 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1100 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1101 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1102 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1103 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1104 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1105 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1106 |
parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1107 |
parent.AddWindow(self.SlaveName, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1108 |
parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1109 |
parent.AddWindow(self.SlaveNodeID, 0, border=10, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1110 |
parent.AddWindow(self.staticText3, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1111 |
parent.AddSizer(self.BottomSizer, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1112 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1113 |
def _init_coll_BottomSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1114 |
parent.AddWindow(self.EDSFile, 0, border=4, flag=wx.GROW|wx.TOP|wx.BOTTOM) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1115 |
parent.AddWindow(self.ImportEDS, 0, border=0, flag=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1116 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1117 |
def _init_coll_BottomSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1118 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1119 |
parent.AddGrowableRow(0) |
205 | 1120 |
|
1121 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1122 |
self.flexGridSizer1 = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1123 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1124 |
self.BottomSizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1125 |
|
205 | 1126 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1127 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1128 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1129 |
self._init_coll_BottomSizer_Items(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1130 |
self._init_coll_BottomSizer_Growables(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1131 |
|
205 | 1132 |
self.SetSizer(self.flexGridSizer1) |
1133 |
||
1134 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1135 |
wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
205 | 1136 |
name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223), |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1137 |
size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
205 | 1138 |
title='Add a slave to nodelist') |
1139 |
self.SetClientSize(wx.Size(300, 250)) |
|
1140 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1141 |
self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1142 |
label='Slave Name:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1143 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1144 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1145 |
self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1146 |
name='SlaveName', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1147 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1148 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1149 |
self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1150 |
label='Slave Node ID:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1151 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1152 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1153 |
self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1154 |
name='SlaveName', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1155 |
size=wx.Size(0, 24), style=wx.ALIGN_RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1156 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1157 |
self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1158 |
label='EDS File:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1159 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1160 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1161 |
self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1162 |
name='EDSFile', parent=self, pos=wx.Point(0, 0), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1163 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1164 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1165 |
self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label='Import EDS', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1166 |
name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
205 | 1167 |
size=wx.Size(100, 32), style=0) |
1168 |
self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton, |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1169 |
id=ID_ADDSLAVEDIALOGIMPORTEDS) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1170 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1171 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1172 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId()) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1173 |
|
205 | 1174 |
self._init_sizers() |
1175 |
||
1176 |
def __init__(self, parent): |
|
1177 |
self._init_ctrls(parent) |
|
1178 |
||
1179 |
self.SlaveNodeID.SetValue("0x00") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1180 |
|
205 | 1181 |
def OnOK(self, event): |
1182 |
error = [] |
|
1183 |
if self.SlaveName.GetValue() == "": |
|
1184 |
error.append("Slave Name") |
|
1185 |
if self.SlaveNodeID.GetValue() == "": |
|
1186 |
error.append("Slave Node ID") |
|
1187 |
if self.EDSFile.GetStringSelection() == "": |
|
1188 |
error.append("EDS File") |
|
1189 |
if len(error) > 0: |
|
1190 |
text = "" |
|
1191 |
for i, item in enumerate(error): |
|
1192 |
if i == 0: |
|
1193 |
text += item |
|
1194 |
elif i == len(error) - 1: |
|
1195 |
text += " and %s"%item |
|
1196 |
else: |
|
1197 |
text += ", %s"%item |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1198 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1199 |
message.ShowModal() |
1200 |
message.Destroy() |
|
1201 |
else: |
|
1202 |
try: |
|
1203 |
nodeid = self.SlaveNodeID.GetValue() |
|
1204 |
if nodeid.find("x") != -1: |
|
1205 |
nodeid = int(nodeid, 16) |
|
1206 |
else: |
|
1207 |
nodeid = int(nodeid) |
|
1208 |
except: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1209 |
message = wx.MessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1210 |
message.ShowModal() |
1211 |
message.Destroy() |
|
1212 |
return |
|
1213 |
if not 0 <= nodeid <= 127: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1214 |
message = wx.MessageDialog(self, "Slave Node ID must be between 0 and 127!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1215 |
message.ShowModal() |
1216 |
message.Destroy() |
|
1217 |
elif nodeid == 0 or nodeid in self.NodeList.SlaveNodes.keys(): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1218 |
message = wx.MessageDialog(self, "A Node with this ID already exist in the network!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1219 |
message.ShowModal() |
1220 |
message.Destroy() |
|
1221 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1222 |
self.EndModal(wx.ID_OK) |
205 | 1223 |
|
1224 |
def OnImportEDSButton(self, event): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1225 |
dialog = wx.FileDialog(self, "Choose an EDS file", os.getcwd(), "", "EDS files (*.eds)|*.eds|All files|*.*", wx.OPEN|wx.CHANGE_DIR) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1226 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 1227 |
filepath = dialog.GetPath() |
1228 |
if os.path.isfile(filepath): |
|
1229 |
result = self.NodeList.ImportEDSFile(filepath) |
|
1230 |
if result: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1231 |
message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1232 |
message.ShowModal() |
1233 |
message.Destroy() |
|
1234 |
dialog.Destroy() |
|
1235 |
self.RefreshEDSFile() |
|
1236 |
event.Skip() |
|
1237 |
||
1238 |
def RefreshEDSFile(self): |
|
1239 |
selection = self.EDSFile.GetStringSelection() |
|
1240 |
self.EDSFile.Clear() |
|
1241 |
for option in self.NodeList.EDSNodes.keys(): |
|
1242 |
self.EDSFile.Append(option) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1243 |
if self.EDSFile.FindString(selection) != wx.NOT_FOUND: |
205 | 1244 |
self.EDSFile.SetStringSelection(selection) |
1245 |
||
1246 |
def SetNodeList(self, nodelist): |
|
1247 |
self.NodeList = nodelist |
|
1248 |
self.RefreshEDSFile() |
|
1249 |
||
1250 |
def GetValues(self): |
|
1251 |
values = {} |
|
1252 |
values["slaveName"] = self.SlaveName.GetValue() |
|
1253 |
nodeid = self.SlaveNodeID.GetValue() |
|
1254 |
if nodeid.find("x") != -1: |
|
1255 |
values["slaveNodeID"] = int(nodeid, 16) |
|
1256 |
else: |
|
1257 |
values["slaveNodeID"] = int(nodeid) |
|
1258 |
values["edsFile"] = self.EDSFile.GetStringSelection() |
|
1259 |
return values |