author | etisserant |
Fri, 21 Sep 2007 08:04:00 +0200 | |
changeset 278 | 9d41c53dadac |
parent 276 | eada6c6c2e87 |
child 299 | 506f9700b9fb |
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 |
|
205 | 731 |
self.Type.Append("master") |
732 |
self.Type.Append("slave") |
|
733 |
||
734 |
def OnOK(self, event): |
|
276 | 735 |
name = self.NodeName.GetValue() |
205 | 736 |
message = "" |
737 |
if name != "": |
|
738 |
good = not name[0].isdigit() |
|
739 |
for item in name.split("_"): |
|
740 |
good &= item.isalnum() |
|
741 |
if not good: |
|
742 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
743 |
if message != "": |
|
744 |
try: |
|
745 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
746 |
except: |
|
747 |
message = "Node ID must be integer!" |
|
748 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
749 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 750 |
message.ShowModal() |
751 |
message.Destroy() |
|
276 | 752 |
self.NodeName.SetFocus() |
205 | 753 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
754 |
self.EndModal(wx.ID_OK) |
205 | 755 |
|
756 |
def SetValues(self, name, id, type, description): |
|
276 | 757 |
self.NodeName.SetValue(name) |
205 | 758 |
self.NodeID.SetValue("0x%02X"%id) |
759 |
self.Type.SetStringSelection(type) |
|
760 |
self.Description.SetValue(description) |
|
761 |
||
762 |
def GetValues(self): |
|
276 | 763 |
name = self.NodeName.GetValue() |
205 | 764 |
nodeid = int(self.NodeID.GetValue(), 16) |
765 |
type = self.Type.GetStringSelection() |
|
766 |
description = self.Description.GetValue() |
|
767 |
return name, nodeid, type, description |
|
768 |
||
769 |
||
770 |
||
771 |
#------------------------------------------------------------------------------- |
|
772 |
# Create New Node Dialog |
|
773 |
#------------------------------------------------------------------------------- |
|
774 |
||
775 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
776 |
[ID_CREATENODEDIALOG, ID_CREATENODEDIALOGEMERGENCY, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
777 |
ID_CREATENODEDIALOGGENSYNC, ID_CREATENODEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
778 |
ID_CREATENODEDIALOGNAME, ID_CREATENODEDIALOGNMT_HEARTBEAT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
779 |
ID_CREATENODEDIALOGNMT_NODEGUARDING, ID_CREATENODEDIALOGNMT_NONE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
780 |
ID_CREATENODEDIALOGNODEID, ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
781 |
ID_CREATENODEDIALOGSAVECONFIG, ID_CREATENODEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
782 |
ID_CREATENODEDIALOGSTATICTEXT2, ID_CREATENODEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
783 |
ID_CREATENODEDIALOGSTATICTEXT4, ID_CREATENODEDIALOGSTATICTEXT5, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
784 |
ID_CREATENODEDIALOGSTATICTEXT6, ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
785 |
ID_CREATENODEDIALOGSTOREEDS, ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
786 |
ID_CREATENODEDIALOGTYPE, |
205 | 787 |
] = [wx.NewId() for _init_ctrls in range(21)] |
788 |
||
789 |
class CreateNodeDialog(wx.Dialog): |
|
790 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
791 |
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
|
792 |
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
|
793 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
794 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
795 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
796 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
797 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
798 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
799 |
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
|
800 |
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
|
801 |
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
|
802 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
803 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
804 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
805 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
806 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
807 |
def _init_coll_TopBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
808 |
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
|
809 |
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
|
810 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
811 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
812 |
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
|
813 |
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
|
814 |
parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
276 | 815 |
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
|
816 |
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
|
817 |
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
|
818 |
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
|
819 |
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
|
820 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
821 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
822 |
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
|
823 |
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
|
824 |
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
|
825 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
826 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
827 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
828 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
829 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
830 |
def _init_coll_RightTopGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
831 |
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
|
832 |
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
|
833 |
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
|
834 |
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
|
835 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
836 |
def _init_coll_RightTopGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
837 |
parent.AddGrowableCol(0) |
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_RightBottomGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
840 |
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
|
841 |
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
|
842 |
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
|
843 |
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
|
844 |
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
|
845 |
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
|
846 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
847 |
def _init_coll_RightBottomGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
848 |
parent.AddGrowableCol(0) |
205 | 849 |
|
850 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
851 |
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
|
852 |
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
|
853 |
self.TopBoxSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
854 |
self.LeftBoxSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
855 |
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
|
856 |
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
|
857 |
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
|
858 |
|
205 | 859 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
860 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
861 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
862 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
863 |
self._init_coll_TopBoxSizer_Items(self.TopBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
864 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
865 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
866 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
867 |
self._init_coll_RightTopGridSizer_Items(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
868 |
self._init_coll_RightTopGridSizer_Growables(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
869 |
self._init_coll_RightBottomGridSizer_Items(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
870 |
self._init_coll_RightBottomGridSizer_Growables(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
871 |
|
205 | 872 |
self.SetSizer(self.flexGridSizer1) |
873 |
||
874 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
875 |
wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
205 | 876 |
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
|
877 |
size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
205 | 878 |
title='Create a new Node') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
879 |
self.SetClientSize(wx.Size(450, 350)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
880 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
881 |
self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
259 | 882 |
label='Type:', name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
883 |
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
|
884 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
885 |
self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
259 | 886 |
label='Name:', name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
887 |
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
|
888 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
889 |
self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
259 | 890 |
label='Node ID:', name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
891 |
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
|
892 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
893 |
self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
894 |
label='Profile:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
895 |
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
|
896 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
897 |
self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
898 |
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
|
899 |
size=wx.Size(0, 25), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
900 |
|
276 | 901 |
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
|
902 |
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
|
903 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
904 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
905 |
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
|
906 |
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
|
907 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
908 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
909 |
self.Profile = wx.Choice(choices=[], id=ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
910 |
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
|
911 |
size=wx.Size(0, 24), style=0) |
205 | 912 |
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
|
913 |
id=ID_CREATENODEDIALOGPROFILE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
914 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
915 |
self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
205 | 916 |
label='Network Management:', name='staticText5', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
917 |
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
|
918 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
919 |
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
|
920 |
label='None', name='NMT_None', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
921 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 922 |
self.NMT_None.SetValue(True) |
923 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
924 |
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
|
925 |
label='Node Guarding', name='NMT_NodeGuarding', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
926 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 927 |
self.NMT_NodeGuarding.SetValue(False) |
928 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
929 |
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
|
930 |
label='Heartbeat', name='NMT_Heartbeat', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
931 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 932 |
self.NMT_Heartbeat.SetValue(False) |
933 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
934 |
self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
935 |
label='Options:', name='staticText6', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
936 |
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
|
937 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
938 |
self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
939 |
label='DS-302 Profile', name='DS302', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
940 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 941 |
self.DS302.SetValue(False) |
942 |
#self.DS302.Enable(False) |
|
943 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
944 |
self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
945 |
label='Generate SYNC', name='GenSYNC', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
946 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 947 |
self.GenSYNC.SetValue(False) |
948 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
949 |
self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
205 | 950 |
label='Emergency support', name='Emergency', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
951 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 952 |
self.Emergency.SetValue(False) |
953 |
self.Emergency.Enable(False) |
|
954 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
955 |
self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
956 |
label='Save Configuration', name='SaveConfig', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
957 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 958 |
self.SaveConfig.SetValue(False) |
959 |
self.SaveConfig.Enable(False) |
|
960 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
961 |
self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
962 |
label='Store EDS', name='StoreEDS', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
963 |
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
|
964 |
self.StoreEDS.SetValue(False) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
965 |
self.StoreEDS.Hide() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
966 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
967 |
self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
968 |
label='Description:', name='staticText7', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
969 |
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
|
970 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
971 |
self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
972 |
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
|
973 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
974 |
|
259 | 975 |
self.Spacer = wx.Panel(id=ID_CREATENODEDIALOGSPACER, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
976 |
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
|
977 |
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
|
978 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
979 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
980 |
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
|
981 |
|
205 | 982 |
self._init_sizers() |
983 |
||
258 | 984 |
def __init__(self, parent): |
205 | 985 |
self._init_ctrls(parent) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
986 |
|
205 | 987 |
self.NodeID.SetValue("0x00") |
988 |
self.Type.Append("master") |
|
989 |
self.Type.Append("slave") |
|
990 |
self.Type.SetStringSelection("slave") |
|
991 |
self.Description.SetValue("") |
|
992 |
self.ListProfile = {"None" : ""} |
|
993 |
self.Profile.Append("None") |
|
258 | 994 |
self.Directory = os.path.join(ScriptDirectory, "config") |
205 | 995 |
listfiles = os.listdir(self.Directory) |
996 |
listfiles.sort() |
|
997 |
for item in listfiles: |
|
998 |
name, extend = os.path.splitext(item) |
|
999 |
if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
|
1000 |
self.ListProfile[name] = os.path.join(self.Directory, item) |
|
1001 |
self.Profile.Append(name) |
|
1002 |
self.Profile.Append("Other") |
|
1003 |
self.Profile.SetStringSelection("None") |
|
276 | 1004 |
self.NodeName.SetFocus() |
205 | 1005 |
|
1006 |
def OnOK(self, event): |
|
276 | 1007 |
name = self.NodeName.GetValue() |
205 | 1008 |
message = "" |
1009 |
if name != "": |
|
1010 |
good = not name[0].isdigit() |
|
1011 |
for item in name.split("_"): |
|
1012 |
good &= item.isalnum() |
|
1013 |
if not good: |
|
1014 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
1015 |
if message != "": |
|
1016 |
try: |
|
1017 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1018 |
except: |
|
1019 |
message = "Node ID must be an integer!" |
|
1020 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1021 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 1022 |
message.ShowModal() |
1023 |
message.Destroy() |
|
276 | 1024 |
self.NodeName.SetFocus() |
205 | 1025 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1026 |
self.EndModal(wx.ID_OK) |
205 | 1027 |
|
1028 |
def GetValues(self): |
|
276 | 1029 |
name = self.NodeName.GetValue() |
205 | 1030 |
nodeid = 0 |
1031 |
if self.NodeID.GetValue() != "": |
|
1032 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1033 |
type = self.Type.GetStringSelection() |
|
1034 |
description = self.Description.GetValue() |
|
1035 |
return name, nodeid, type, description |
|
1036 |
||
1037 |
def GetProfile(self): |
|
1038 |
name = self.Profile.GetStringSelection() |
|
1039 |
return name, self.ListProfile[name] |
|
1040 |
||
1041 |
def GetNMTManagement(self): |
|
1042 |
if self.NMT_None.GetValue(): |
|
1043 |
return "None" |
|
1044 |
elif self.NMT_NodeGuarding.GetValue(): |
|
1045 |
return "NodeGuarding" |
|
1046 |
elif self.NMT_Heartbeat.GetValue(): |
|
1047 |
return "Heartbeat" |
|
1048 |
return None |
|
1049 |
||
1050 |
def GetOptions(self): |
|
1051 |
options = [] |
|
1052 |
if self.DS302.GetValue(): |
|
1053 |
options.append("DS302") |
|
1054 |
if self.GenSYNC.GetValue(): |
|
1055 |
options.append("GenSYNC") |
|
1056 |
if self.Emergency.GetValue(): |
|
1057 |
options.append("Emergency") |
|
1058 |
if self.SaveConfig.GetValue(): |
|
1059 |
options.append("SaveConfig") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1060 |
if self.StoreEDS.GetValue(): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1061 |
options.append("StoreEDS") |
205 | 1062 |
return options |
1063 |
||
1064 |
def OnProfileChoice(self, event): |
|
1065 |
if self.Profile.GetStringSelection() == "Other": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1066 |
dialog = wx.FileDialog(self, "Choose a file", self.Directory, "", "OD Profile files (*.prf)|*.prf|All files|*.*", wx.OPEN|wx.CHANGE_DIR) |
205 | 1067 |
dialog.ShowModal() |
1068 |
filepath = dialog.GetPath() |
|
1069 |
dialog.Destroy() |
|
1070 |
if os.path.isfile(filepath): |
|
1071 |
name = os.path.splitext(os.path.basename(filepath))[0] |
|
1072 |
self.ListProfile[name] = filepath |
|
1073 |
length = self.Profile.GetCount() |
|
1074 |
self.Profile.Insert(name, length - 2) |
|
1075 |
self.Profile.SetStringSelection(name) |
|
1076 |
else: |
|
1077 |
self.Profile.SetStringSelection("None") |
|
1078 |
event.Skip() |
|
1079 |
||
1080 |
||
1081 |
#------------------------------------------------------------------------------- |
|
1082 |
# ADD Slave to NodeList Dialog |
|
1083 |
#------------------------------------------------------------------------------- |
|
1084 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1085 |
[ID_ADDSLAVEDIALOG, ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1086 |
ID_ADDSLAVEDIALOGSLAVENODEID, ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1087 |
ID_ADDSLAVEDIALOGIMPORTEDS, ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1088 |
ID_ADDSLAVEDIALOGSTATICTEXT2, ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1089 |
] = [wx.NewId() for _init_ctrls in range(8)] |
205 | 1090 |
|
1091 |
class AddSlaveDialog(wx.Dialog): |
|
1092 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1093 |
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
|
1094 |
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
|
1095 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1096 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1097 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1098 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1099 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1100 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1101 |
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
|
1102 |
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
|
1103 |
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
|
1104 |
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
|
1105 |
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
|
1106 |
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
|
1107 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1108 |
def _init_coll_BottomSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1109 |
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
|
1110 |
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
|
1111 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1112 |
def _init_coll_BottomSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1113 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1114 |
parent.AddGrowableRow(0) |
205 | 1115 |
|
1116 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1117 |
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
|
1118 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1119 |
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
|
1120 |
|
205 | 1121 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1122 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1123 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1124 |
self._init_coll_BottomSizer_Items(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1125 |
self._init_coll_BottomSizer_Growables(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1126 |
|
205 | 1127 |
self.SetSizer(self.flexGridSizer1) |
1128 |
||
1129 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1130 |
wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
205 | 1131 |
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
|
1132 |
size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
205 | 1133 |
title='Add a slave to nodelist') |
1134 |
self.SetClientSize(wx.Size(300, 250)) |
|
1135 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1136 |
self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1137 |
label='Slave Name:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1138 |
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
|
1139 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1140 |
self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1141 |
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
|
1142 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1143 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1144 |
self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1145 |
label='Slave Node ID:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1146 |
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
|
1147 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1148 |
self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1149 |
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
|
1150 |
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
|
1151 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1152 |
self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1153 |
label='EDS File:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1154 |
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
|
1155 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1156 |
self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1157 |
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
|
1158 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1159 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1160 |
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
|
1161 |
name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
205 | 1162 |
size=wx.Size(100, 32), style=0) |
1163 |
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
|
1164 |
id=ID_ADDSLAVEDIALOGIMPORTEDS) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1165 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1166 |
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
|
1167 |
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
|
1168 |
|
205 | 1169 |
self._init_sizers() |
1170 |
||
1171 |
def __init__(self, parent): |
|
1172 |
self._init_ctrls(parent) |
|
1173 |
||
1174 |
self.SlaveNodeID.SetValue("0x00") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1175 |
|
205 | 1176 |
def OnOK(self, event): |
1177 |
error = [] |
|
1178 |
if self.SlaveName.GetValue() == "": |
|
1179 |
error.append("Slave Name") |
|
1180 |
if self.SlaveNodeID.GetValue() == "": |
|
1181 |
error.append("Slave Node ID") |
|
1182 |
if self.EDSFile.GetStringSelection() == "": |
|
1183 |
error.append("EDS File") |
|
1184 |
if len(error) > 0: |
|
1185 |
text = "" |
|
1186 |
for i, item in enumerate(error): |
|
1187 |
if i == 0: |
|
1188 |
text += item |
|
1189 |
elif i == len(error) - 1: |
|
1190 |
text += " and %s"%item |
|
1191 |
else: |
|
1192 |
text += ", %s"%item |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1193 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1194 |
message.ShowModal() |
1195 |
message.Destroy() |
|
1196 |
else: |
|
1197 |
try: |
|
1198 |
nodeid = self.SlaveNodeID.GetValue() |
|
1199 |
if nodeid.find("x") != -1: |
|
1200 |
nodeid = int(nodeid, 16) |
|
1201 |
else: |
|
1202 |
nodeid = int(nodeid) |
|
1203 |
except: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1204 |
message = wx.MessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1205 |
message.ShowModal() |
1206 |
message.Destroy() |
|
1207 |
return |
|
1208 |
if not 0 <= nodeid <= 127: |
|
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 between 0 and 127!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1210 |
message.ShowModal() |
1211 |
message.Destroy() |
|
1212 |
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
|
1213 |
message = wx.MessageDialog(self, "A Node with this ID already exist in the network!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1214 |
message.ShowModal() |
1215 |
message.Destroy() |
|
1216 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1217 |
self.EndModal(wx.ID_OK) |
205 | 1218 |
|
1219 |
def OnImportEDSButton(self, event): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1220 |
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
|
1221 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 1222 |
filepath = dialog.GetPath() |
1223 |
if os.path.isfile(filepath): |
|
1224 |
result = self.NodeList.ImportEDSFile(filepath) |
|
1225 |
if result: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1226 |
message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1227 |
message.ShowModal() |
1228 |
message.Destroy() |
|
1229 |
dialog.Destroy() |
|
1230 |
self.RefreshEDSFile() |
|
1231 |
event.Skip() |
|
1232 |
||
1233 |
def RefreshEDSFile(self): |
|
1234 |
selection = self.EDSFile.GetStringSelection() |
|
1235 |
self.EDSFile.Clear() |
|
1236 |
for option in self.NodeList.EDSNodes.keys(): |
|
1237 |
self.EDSFile.Append(option) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1238 |
if self.EDSFile.FindString(selection) != wx.NOT_FOUND: |
205 | 1239 |
self.EDSFile.SetStringSelection(selection) |
1240 |
||
1241 |
def SetNodeList(self, nodelist): |
|
1242 |
self.NodeList = nodelist |
|
1243 |
self.RefreshEDSFile() |
|
1244 |
||
1245 |
def GetValues(self): |
|
1246 |
values = {} |
|
1247 |
values["slaveName"] = self.SlaveName.GetValue() |
|
1248 |
nodeid = self.SlaveNodeID.GetValue() |
|
1249 |
if nodeid.find("x") != -1: |
|
1250 |
values["slaveNodeID"] = int(nodeid, 16) |
|
1251 |
else: |
|
1252 |
values["slaveNodeID"] = int(nodeid) |
|
1253 |
values["edsFile"] = self.EDSFile.GetStringSelection() |
|
1254 |
return values |