author | etisserant |
Wed, 18 Jun 2008 11:15:17 +0200 | |
changeset 482 | ec49f7132e36 |
parent 452 | 9b67c71adbb7 |
child 486 | edf526bd34b5 |
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 |
|
359
346435b94063
Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents:
328
diff
changeset
|
25 |
import wx.grid |
205 | 26 |
|
27 |
import os |
|
28 |
||
327 | 29 |
from node import BE_to_LE, LE_to_BE |
30 |
||
258 | 31 |
ScriptDirectory = os.path.split(__file__)[0] |
32 |
||
205 | 33 |
#------------------------------------------------------------------------------- |
34 |
# Editing Communication Dialog |
|
35 |
#------------------------------------------------------------------------------- |
|
36 |
||
37 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
38 |
[ID_COMMUNICATIONDIALOG, ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
39 |
ID_COMMUNICATIONDIALOGCURRENTINDEXES, ID_COMMUNICATIONDIALOGSELECT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
40 |
ID_COMMUNICATIONDIALOGUNSELECT, ID_COMMUNICATIONDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
41 |
ID_COMMUNICATIONDIALOGSTATICTEXT2 |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
42 |
] = [wx.NewId() for _init_ctrls in range(7)] |
205 | 43 |
|
44 |
class CommunicationDialog(wx.Dialog): |
|
45 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
49 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
50 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
51 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
52 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
53 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
58 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
59 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
60 |
parent.AddGrowableCol(2) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
61 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
62 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
63 |
def _init_coll_LeftGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
64 |
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
|
65 |
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
|
66 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
67 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
68 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
69 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
70 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
71 |
def _init_coll_MiddleGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
75 |
def _init_coll_MiddleGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
76 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
77 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
78 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
79 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
80 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
81 |
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
|
82 |
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
|
83 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
84 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
85 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
86 |
parent.AddGrowableRow(1) |
205 | 87 |
|
88 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
|
205 | 95 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
96 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
97 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
98 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
99 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
100 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
101 |
self._init_coll_MiddleGridSizer_Items(self.MiddleGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
102 |
self._init_coll_MiddleGridSizer_Growables(self.MiddleGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
103 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
104 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
105 |
|
205 | 106 |
self.SetSizer(self.flexGridSizer1) |
107 |
||
108 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
109 |
wx.Dialog.__init__(self, id=ID_COMMUNICATIONDIALOG, |
205 | 110 |
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
|
111 |
size=wx.Size(726, 437), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
205 | 112 |
title='Edit Communication Profile') |
113 |
self.SetClientSize(wx.Size(726, 437)) |
|
114 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
115 |
self.staticText1 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
116 |
label='Possible Profile Indexes:', name='staticText1', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
117 |
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
|
118 |
17), style=0) |
205 | 119 |
|
120 |
self.PossibleIndexes = wx.ListBox(choices=[], |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
121 |
id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
122 |
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
|
123 |
size=wx.Size(0, 0), style=wx.LB_EXTENDED) |
266 | 124 |
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
|
125 |
id=ID_COMMUNICATIONDIALOGPOSSIBLEINDEXES) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
126 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
127 |
self.Select = wx.Button(id=ID_COMMUNICATIONDIALOGSELECT, label='>>', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
128 |
name='Select', parent=self, pos=wx.Point(0, 0), |
205 | 129 |
size=wx.Size(32, 32), style=0) |
130 |
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
|
131 |
id=ID_COMMUNICATIONDIALOGSELECT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
132 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
133 |
self.Unselect = wx.Button(id=ID_COMMUNICATIONDIALOGUNSELECT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
134 |
label='<<', name='Unselect', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
135 |
pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) |
205 | 136 |
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
|
137 |
id=ID_COMMUNICATIONDIALOGUNSELECT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
138 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
139 |
self.staticText2 = wx.StaticText(id=ID_COMMUNICATIONDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
140 |
label='Current Profile Indexes:', name='staticText2', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
141 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, |
205 | 142 |
17), style=0) |
143 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
144 |
self.CurrentIndexes = wx.ListBox(choices=[], |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
145 |
id=ID_COMMUNICATIONDIALOGCURRENTINDEXES, name='CurrentIndexes', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
146 |
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
|
147 |
style=wx.LB_EXTENDED) |
266 | 148 |
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
|
149 |
id=ID_COMMUNICATIONDIALOGCURRENTINDEXES) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
150 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
151 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
152 |
|
205 | 153 |
self._init_sizers() |
154 |
||
155 |
def __init__(self, parent): |
|
156 |
self._init_ctrls(parent) |
|
157 |
self.AllList = [] |
|
158 |
self.CurrentList = [] |
|
159 |
self.IndexDictionary = {} |
|
160 |
||
161 |
def SetIndexDictionary(self, dictionary): |
|
162 |
self.IndexDictionary = dictionary |
|
163 |
||
164 |
def SetCurrentList(self, list): |
|
165 |
self.CurrentList = [] |
|
166 |
self.CurrentList.extend(list) |
|
167 |
self.CurrentList.sort() |
|
168 |
||
169 |
def GetCurrentList(self): |
|
170 |
return self.CurrentList |
|
171 |
||
172 |
def RefreshLists(self): |
|
173 |
self.PossibleIndexes.Clear() |
|
174 |
self.CurrentIndexes.Clear() |
|
175 |
self.AllList = [] |
|
176 |
for index in self.IndexDictionary.iterkeys(): |
|
177 |
if index not in self.CurrentList: |
|
178 |
self.AllList.append(index) |
|
179 |
self.AllList.sort() |
|
180 |
for index in self.AllList: |
|
181 |
self.PossibleIndexes.Append("0x%04X %s"%(index, self.IndexDictionary[index][0])) |
|
182 |
for index in self.CurrentList: |
|
183 |
if index in self.IndexDictionary: |
|
184 |
self.CurrentIndexes.Append("0x%04X %s"%(index, self.IndexDictionary[index][0])) |
|
185 |
||
186 |
def OnPossibleIndexesDClick(self, event): |
|
187 |
self.SelectPossible() |
|
188 |
event.Skip() |
|
189 |
||
190 |
def OnCurrentIndexesDClick(self, event): |
|
191 |
self.UnselectCurrent() |
|
192 |
event.Skip() |
|
193 |
||
194 |
def OnSelectButton(self, event): |
|
195 |
self.SelectPossible() |
|
196 |
event.Skip() |
|
197 |
||
198 |
def OnUnselectButton(self, event): |
|
199 |
self.UnselectCurrent() |
|
200 |
event.Skip() |
|
201 |
||
202 |
def SelectPossible(self): |
|
203 |
selected = self.PossibleIndexes.GetSelections() |
|
204 |
for i in selected: |
|
205 |
self.CurrentList.append(self.AllList[i]) |
|
206 |
self.CurrentList.sort() |
|
207 |
self.RefreshLists() |
|
208 |
||
209 |
def UnselectCurrent(self): |
|
210 |
selected = self.CurrentIndexes.GetSelections() |
|
211 |
for i in selected: |
|
212 |
if not self.IndexDictionary[self.CurrentList[i]][1]: |
|
213 |
self.CurrentList.pop(i) |
|
214 |
self.CurrentList.sort() |
|
215 |
self.RefreshLists() |
|
216 |
||
217 |
||
218 |
||
219 |
#------------------------------------------------------------------------------- |
|
220 |
# Create Map Variable Dialog |
|
221 |
#------------------------------------------------------------------------------- |
|
222 |
||
223 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
224 |
[ID_MAPVARIABLEDIALOG, ID_MAPVARIABLEDIALOGINDEX, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
225 |
ID_MAPVARIABLEDIALOGINDEXNAME, ID_MAPVARIABLEDIALOGSPACER, |
259 | 226 |
ID_MAPVARIABLEDIALOGSPACER2, ID_MAPVARIABLEDIALOGNUMBER, |
227 |
ID_MAPVARIABLEDIALOGRADIOBUTTON1, ID_MAPVARIABLEDIALOGRADIOBUTTON2, |
|
228 |
ID_MAPVARIABLEDIALOGRADIOBUTTON3, ID_MAPVARIABLEDIALOGSTATICTEXT1, |
|
229 |
ID_MAPVARIABLEDIALOGSTATICTEXT2, ID_MAPVARIABLEDIALOGSTATICTEXT3, |
|
230 |
ID_MAPVARIABLEDIALOGSTATICTEXT4, |
|
231 |
] = [wx.NewId() for _init_ctrls in range(13)] |
|
205 | 232 |
|
233 |
class MapVariableDialog(wx.Dialog): |
|
234 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
235 |
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
|
236 |
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
|
237 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
238 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
239 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
240 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
241 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
242 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
243 |
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
|
244 |
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
|
245 |
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
|
246 |
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
|
247 |
parent.AddWindow(self.radioButton1, 0, border=0, flag=wx.GROW) |
259 | 248 |
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
|
249 |
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
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
256 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
257 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
258 |
parent.AddGrowableCol(2) |
205 | 259 |
|
260 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
261 |
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
|
262 |
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
|
263 |
|
205 | 264 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
265 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
266 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
267 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
268 |
|
205 | 269 |
self.SetSizer(self.flexGridSizer1) |
270 |
||
271 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
272 |
wx.Dialog.__init__(self, id=ID_MAPVARIABLEDIALOG, |
205 | 273 |
name='CommunicationDialog', parent=prnt, pos=wx.Point(376, 223), |
274 |
size=wx.Size(444, 186), style=wx.DEFAULT_DIALOG_STYLE, |
|
275 |
title='Add Map Variable') |
|
276 |
self.SetClientSize(wx.Size(444, 186)) |
|
277 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
278 |
self.staticText1 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
279 |
label='Index:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
280 |
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
|
281 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
282 |
self.staticText2 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
283 |
label='Type:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
284 |
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
|
285 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
286 |
self.staticText3 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
287 |
label='Name:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
288 |
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
|
289 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
290 |
self.staticText4 = wx.StaticText(id=ID_MAPVARIABLEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
291 |
label='Number:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
292 |
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
|
293 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
294 |
self.radioButton1 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
295 |
label='VAR', name='radioButton1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
296 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_GROUP) |
205 | 297 |
self.radioButton1.SetValue(True) |
298 |
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
|
299 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
300 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
301 |
self.radioButton2 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
302 |
label='ARRAY', name='radioButton2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
303 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE) |
205 | 304 |
self.radioButton2.SetValue(False) |
305 |
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
|
306 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON2) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
307 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
308 |
self.radioButton3 = wx.RadioButton(id=ID_MAPVARIABLEDIALOGRADIOBUTTON3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
309 |
label='REC', name='radioButton3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
310 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=wx.RB_SINGLE) |
205 | 311 |
self.radioButton3.SetValue(False) |
312 |
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
|
313 |
id=ID_MAPVARIABLEDIALOGRADIOBUTTON3) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
314 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
315 |
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
|
316 |
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
|
317 |
style=0, value='0x2000') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
318 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
319 |
self.IndexName = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGINDEXNAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
320 |
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
|
321 |
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
|
322 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
323 |
self.Number = wx.TextCtrl(id=ID_MAPVARIABLEDIALOGNUMBER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
324 |
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
|
325 |
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
|
326 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
327 |
self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
328 |
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
|
329 |
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
|
330 |
|
259 | 331 |
self.Spacer2 = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER2, |
332 |
name='Spacer2', parent=self, pos=wx.Point(0, 0), |
|
333 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
334 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
335 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
336 |
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
|
337 |
|
205 | 338 |
self._init_sizers() |
339 |
||
340 |
def __init__(self, parent): |
|
341 |
self._init_ctrls(parent) |
|
342 |
self.staticText4.Enable(False) |
|
343 |
self.Number.Enable(False) |
|
344 |
||
345 |
def SetIndex(self, index): |
|
346 |
self.Index.SetValue("0x%04X"%index) |
|
347 |
||
348 |
def OnOK(self, event): |
|
349 |
error = [] |
|
350 |
try: |
|
351 |
int(self.Index.GetValue(), 16) |
|
352 |
except: |
|
353 |
error.append("Index") |
|
354 |
if self.radioButton2.GetValue() or self.radioButton3.GetValue(): |
|
355 |
try: |
|
356 |
int(self.Number.GetValue()) |
|
357 |
except: |
|
358 |
error.append("Number") |
|
359 |
if len(error) > 0: |
|
360 |
text = "" |
|
361 |
if len(error) > 1: |
|
362 |
suffix = "s" |
|
363 |
else: |
|
364 |
suffix = "" |
|
365 |
for i, item in enumerate(error): |
|
366 |
if i == 0: |
|
367 |
text += item |
|
368 |
elif i == len(error) - 1: |
|
369 |
text += " and %s"%item |
|
370 |
else: |
|
371 |
text += ", %s"%item |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
372 |
message = wx.MessageDialog(self, "Form isn't valid. %s must be integer%s!"%(text,suffix), "Error", wx.OK|wx.ICON_ERROR) |
205 | 373 |
message.ShowModal() |
374 |
message.Destroy() |
|
375 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
376 |
self.EndModal(wx.ID_OK) |
205 | 377 |
|
378 |
def GetValues(self): |
|
379 |
name = self.IndexName.GetValue() |
|
380 |
index = int(self.Index.GetValue(), 16) |
|
381 |
if self.radioButton1.GetValue(): |
|
382 |
struct = 1 |
|
383 |
number = None |
|
384 |
elif self.radioButton2.GetValue(): |
|
452 | 385 |
struct = 7 |
205 | 386 |
number = int(self.Number.GetValue()) |
387 |
elif self.radioButton3.GetValue(): |
|
452 | 388 |
struct = 3 |
205 | 389 |
number = int(self.Number.GetValue()) |
390 |
return index, name, struct, number |
|
391 |
||
392 |
def OnRadioButton1Click(self, event): |
|
393 |
self.EnableNumberTyping(False) |
|
394 |
event.Skip() |
|
395 |
||
396 |
def OnRadioButton2Click(self, event): |
|
397 |
self.EnableNumberTyping(True) |
|
398 |
event.Skip() |
|
399 |
||
400 |
def OnRadioButton3Click(self, event): |
|
401 |
self.EnableNumberTyping(True) |
|
402 |
event.Skip() |
|
403 |
||
404 |
def EnableNumberTyping(self, enable): |
|
405 |
self.staticText4.Enable(enable) |
|
406 |
self.Number.Enable(enable) |
|
407 |
||
408 |
||
409 |
#------------------------------------------------------------------------------- |
|
410 |
# Create User Type Dialog |
|
411 |
#------------------------------------------------------------------------------- |
|
412 |
||
413 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
414 |
[ID_USERTYPEDIALOG, ID_USERTYPEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
415 |
ID_USERTYPEDIALOGTYPE, ID_USERTYPEDIALOGMAX, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
416 |
ID_USERTYPEDIALOGMIN, ID_USERTYPEDIALOGLENGTH, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
417 |
ID_USERTYPEDIALOGSTATICBOX1, ID_USERTYPEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
418 |
ID_USERTYPEDIALOGSTATICTEXT2, ID_USERTYPEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
419 |
ID_USERTYPEDIALOGSTATICTEXT4, |
205 | 420 |
] = [wx.NewId() for _init_ctrls in range(11)] |
421 |
||
422 |
class UserTypeDialog(wx.Dialog): |
|
423 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
424 |
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
|
425 |
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
|
426 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
427 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
428 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
429 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
430 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
431 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
432 |
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
|
433 |
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
|
434 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
435 |
def _init_coll_LeftGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
436 |
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
|
437 |
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
|
438 |
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
|
439 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
440 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
441 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
442 |
parent.AddGrowableRow(2) |
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_RightBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
445 |
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
|
446 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
447 |
def _init_coll_RightBoxGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
455 |
def _init_coll_RightBoxGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
456 |
parent.AddGrowableCol(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
457 |
|
205 | 458 |
def _init_sizers(self): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
459 |
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
|
460 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
461 |
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
|
462 |
self.RightBoxSizer = wx.StaticBoxSizer(self.staticBox1, wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
463 |
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
|
464 |
|
205 | 465 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
466 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
467 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
468 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
469 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
470 |
self._init_coll_RightBoxSizer_Items(self.RightBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
471 |
self._init_coll_RightBoxGridSizer_Items(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
472 |
self._init_coll_RightBoxGridSizer_Growables(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
473 |
|
205 | 474 |
self.SetSizer(self.flexGridSizer1) |
475 |
||
476 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
477 |
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
|
478 |
parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210), |
205 | 479 |
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
|
480 |
self.SetClientSize(wx.Size(444, 210)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
481 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
482 |
self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
483 |
label='Type:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
484 |
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
|
485 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
486 |
self.Type = wx.Choice(choices=[], id=ID_USERTYPEDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
487 |
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
|
488 |
size=wx.Size(0, 24), style=0) |
205 | 489 |
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
|
490 |
id=ID_USERTYPEDIALOGTYPE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
491 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
492 |
self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
493 |
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
|
494 |
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
|
495 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
496 |
self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
497 |
label='Values', name='staticBox1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
498 |
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
|
499 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
500 |
self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
501 |
label='Minimum:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
502 |
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
|
503 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
504 |
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
|
505 |
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
|
506 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
507 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
508 |
self.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
509 |
label='Maximum:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
510 |
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
|
511 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
512 |
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
|
513 |
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
|
514 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
515 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
516 |
self.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
517 |
label='Length:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
518 |
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
|
519 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
520 |
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
|
521 |
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
|
522 |
style=wx.TE_RIGHT, value='0') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
523 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
524 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
525 |
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
|
526 |
|
205 | 527 |
self._init_sizers() |
528 |
||
529 |
def __init__(self, parent): |
|
530 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
531 |
|
205 | 532 |
self.TypeDictionary = {} |
533 |
||
534 |
def OnOK(self, event): |
|
535 |
error = [] |
|
536 |
good = True |
|
537 |
firstmessage = "" |
|
538 |
secondmessage = "" |
|
539 |
name = self.Type.GetStringSelection() |
|
540 |
if name != "": |
|
541 |
valuetype = self.TypeDictionary[name][1] |
|
542 |
if valuetype == 0: |
|
543 |
try: |
|
544 |
int(self.Min.GetValue(), 16) |
|
545 |
except: |
|
546 |
error.append("Minimum") |
|
547 |
good = False |
|
548 |
try: |
|
549 |
int(self.Max.GetValue(), 16) |
|
550 |
except: |
|
551 |
error.append("Maximum") |
|
552 |
good = False |
|
553 |
elif valuetype == 1: |
|
554 |
try: |
|
555 |
int(self.Length.GetValue(), 16) |
|
556 |
except: |
|
557 |
error.append("Length") |
|
558 |
good = False |
|
559 |
if len(error) > 0: |
|
560 |
secondmessage = ". " |
|
561 |
for i, item in enumerate(error): |
|
562 |
if i == 0: |
|
563 |
secondmessage += item |
|
564 |
elif i == len(error) - 1: |
|
565 |
secondmessage += " and %s"%item |
|
566 |
else: |
|
567 |
secondmessage += ", %s"%item |
|
568 |
secondmessage += " must be integer" |
|
569 |
if len(error) > 1: |
|
570 |
secondmessage += "s" |
|
571 |
else: |
|
572 |
firstmessage = ". A type must be selected" |
|
573 |
good = False |
|
574 |
if not good: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
575 |
message = wx.MessageDialog(self, "Form isn't valid%s%s%s!"%(firstmessage,secondmessage), "Error", wx.OK|wx.ICON_ERROR) |
205 | 576 |
message.ShowModal() |
577 |
message.Destroy() |
|
578 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
579 |
self.EndModal(wx.ID_OK) |
205 | 580 |
|
581 |
def SetValues(self, min = None, max = None, length = None): |
|
582 |
if min != None: |
|
583 |
self.Min.SetValue(str(min)) |
|
584 |
if max != None: |
|
585 |
self.Max.SetValue(str(max)) |
|
586 |
if length != None: |
|
587 |
self.Length.SetValue(str(length)) |
|
588 |
||
589 |
def SetTypeList(self, typedic, type = None): |
|
590 |
self.Type.Clear() |
|
591 |
list = [] |
|
592 |
for index, (name, valuetype) in typedic.iteritems(): |
|
593 |
self.TypeDictionary[name] = (index, valuetype) |
|
594 |
list.append((index, name)) |
|
595 |
list.sort() |
|
596 |
for index, name in list: |
|
597 |
self.Type.Append(name) |
|
598 |
if type != None: |
|
599 |
self.Type.SetStringSelection(typedic[type][0]) |
|
600 |
self.RefreshValues() |
|
601 |
||
602 |
def OnTypeChoice(self, event): |
|
603 |
self.RefreshValues() |
|
604 |
event.Skip() |
|
605 |
||
606 |
def RefreshValues(self): |
|
607 |
name = self.Type.GetStringSelection() |
|
608 |
if name != "": |
|
609 |
valuetype = self.TypeDictionary[name][1] |
|
610 |
if valuetype == 0: |
|
611 |
self.staticText2.Enable(True) |
|
612 |
self.staticText3.Enable(True) |
|
613 |
self.staticText4.Enable(False) |
|
614 |
self.Min.Enable(True) |
|
615 |
self.Max.Enable(True) |
|
616 |
self.Length.Enable(False) |
|
617 |
elif valuetype == 1: |
|
618 |
self.staticText2.Enable(False) |
|
619 |
self.staticText3.Enable(False) |
|
620 |
self.staticText4.Enable(True) |
|
621 |
self.Min.Enable(False) |
|
622 |
self.Max.Enable(False) |
|
623 |
self.Length.Enable(True) |
|
624 |
else: |
|
625 |
self.staticText2.Enable(False) |
|
626 |
self.staticText3.Enable(False) |
|
627 |
self.staticText4.Enable(False) |
|
628 |
self.Min.Enable(False) |
|
629 |
self.Max.Enable(False) |
|
630 |
self.Length.Enable(False) |
|
631 |
||
632 |
def GetValues(self): |
|
633 |
name = self.Type.GetStringSelection() |
|
634 |
type = self.TypeDictionary[name][0] |
|
635 |
min = int(self.Min.GetValue()) |
|
636 |
max = int(self.Max.GetValue()) |
|
637 |
length = int(self.Length.GetValue()) |
|
638 |
return type, min, max, length |
|
639 |
||
640 |
||
641 |
||
642 |
#------------------------------------------------------------------------------- |
|
643 |
# Editing Node Infos Dialog |
|
644 |
#------------------------------------------------------------------------------- |
|
645 |
||
646 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
647 |
[ID_NODEINFOSDIALOG, ID_NODEINFOSDIALOGNAME, |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
648 |
ID_NODEINFOSDIALOGNODEID, ID_NODEINFOSDIALOGTYPE, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
649 |
ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, ID_NODEINFOSDIALOGDESCRIPTION, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
650 |
ID_NODEINFOSDIALOGSTATICTEXT1, ID_NODEINFOSDIALOGSTATICTEXT2, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
651 |
ID_NODEINFOSDIALOGSTATICTEXT3, ID_NODEINFOSDIALOGSTATICTEXT4, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
652 |
ID_NODEINFOSDIALOGSTATICTEXT5, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
653 |
] = [wx.NewId() for _init_ctrls in range(11)] |
205 | 654 |
|
655 |
class NodeInfosDialog(wx.Dialog): |
|
656 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
660 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
661 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
662 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
663 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
664 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
665 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
276 | 666 |
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
|
667 |
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
|
668 |
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
|
669 |
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
|
670 |
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
|
671 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
672 |
parent.AddWindow(self.DefaultStringSize, 0, border=0, flag=wx.GROW) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
673 |
parent.AddWindow(self.staticText5, 0, border=0, flag=wx.GROW) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
674 |
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
|
675 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
676 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
677 |
parent.AddGrowableCol(0) |
205 | 678 |
|
679 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
680 |
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
|
681 |
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
|
682 |
|
205 | 683 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
684 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
685 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
686 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
687 |
|
205 | 688 |
self.SetSizer(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
689 |
|
205 | 690 |
def _init_ctrls(self, prnt): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
691 |
wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG, |
205 | 692 |
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
|
693 |
size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE, |
205 | 694 |
title='Node Infos') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
695 |
self.SetClientSize(wx.Size(300, 280)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
696 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
697 |
self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
698 |
label='Name:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
699 |
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
|
700 |
|
276 | 701 |
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
|
702 |
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
|
703 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
704 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
705 |
self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
706 |
label='Node ID:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
707 |
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
|
708 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
709 |
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
|
710 |
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
|
711 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
712 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
713 |
self.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
714 |
label='Type:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
715 |
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
|
716 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
717 |
self.Type = wx.Choice(choices=[], id=ID_NODEINFOSDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
718 |
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
|
719 |
size=wx.Size(0, 25), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
720 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
721 |
self.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4, |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
722 |
label='Default String Size:', name='staticText4', parent=self, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
723 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
724 |
|
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
725 |
self.DefaultStringSize = wx.SpinCtrl(id=ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
726 |
name='DefaultStringSize', parent=self, pos=wx.Point(0, 0), |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
727 |
size=wx.Size(0, 25), style=wx.TE_RIGHT) |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
728 |
|
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
729 |
self.staticText5 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT5, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
730 |
label='Description:', name='staticText5', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
731 |
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
|
732 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
733 |
self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
734 |
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
|
735 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
736 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
737 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
738 |
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
|
739 |
|
205 | 740 |
self._init_sizers() |
741 |
||
742 |
def __init__(self, parent): |
|
743 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
744 |
|
299 | 745 |
self.staticText2.Hide() |
746 |
self.NodeID.Hide() |
|
747 |
||
205 | 748 |
self.Type.Append("master") |
749 |
self.Type.Append("slave") |
|
750 |
||
751 |
def OnOK(self, event): |
|
276 | 752 |
name = self.NodeName.GetValue() |
205 | 753 |
message = "" |
754 |
if name != "": |
|
755 |
good = not name[0].isdigit() |
|
756 |
for item in name.split("_"): |
|
757 |
good &= item.isalnum() |
|
758 |
if not good: |
|
759 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
760 |
if message != "": |
|
761 |
try: |
|
762 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
763 |
except: |
|
764 |
message = "Node ID must be integer!" |
|
765 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
766 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 767 |
message.ShowModal() |
768 |
message.Destroy() |
|
276 | 769 |
self.NodeName.SetFocus() |
205 | 770 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
771 |
self.EndModal(wx.ID_OK) |
205 | 772 |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
773 |
def SetValues(self, name, id, type, description, defaultstringsize): |
276 | 774 |
self.NodeName.SetValue(name) |
205 | 775 |
self.NodeID.SetValue("0x%02X"%id) |
776 |
self.Type.SetStringSelection(type) |
|
777 |
self.Description.SetValue(description) |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
778 |
self.DefaultStringSize.SetValue(defaultstringsize) |
205 | 779 |
|
780 |
def GetValues(self): |
|
276 | 781 |
name = self.NodeName.GetValue() |
205 | 782 |
nodeid = int(self.NodeID.GetValue(), 16) |
783 |
type = self.Type.GetStringSelection() |
|
784 |
description = self.Description.GetValue() |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
785 |
defaultstringsize = self.DefaultStringSize.GetValue() |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
786 |
return name, nodeid, type, description, defaultstringsize |
205 | 787 |
|
788 |
||
789 |
||
790 |
#------------------------------------------------------------------------------- |
|
791 |
# Create New Node Dialog |
|
792 |
#------------------------------------------------------------------------------- |
|
793 |
||
794 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
795 |
[ID_CREATENODEDIALOG, ID_CREATENODEDIALOGEMERGENCY, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
796 |
ID_CREATENODEDIALOGGENSYNC, ID_CREATENODEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
797 |
ID_CREATENODEDIALOGNAME, ID_CREATENODEDIALOGNMT_HEARTBEAT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
798 |
ID_CREATENODEDIALOGNMT_NODEGUARDING, ID_CREATENODEDIALOGNMT_NONE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
799 |
ID_CREATENODEDIALOGNODEID, ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
800 |
ID_CREATENODEDIALOGSAVECONFIG, ID_CREATENODEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
801 |
ID_CREATENODEDIALOGSTATICTEXT2, ID_CREATENODEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
802 |
ID_CREATENODEDIALOGSTATICTEXT4, ID_CREATENODEDIALOGSTATICTEXT5, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
803 |
ID_CREATENODEDIALOGSTATICTEXT6, ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
804 |
ID_CREATENODEDIALOGSTOREEDS, ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
805 |
ID_CREATENODEDIALOGTYPE, |
205 | 806 |
] = [wx.NewId() for _init_ctrls in range(21)] |
807 |
||
808 |
class CreateNodeDialog(wx.Dialog): |
|
809 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
810 |
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
|
811 |
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
|
812 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
813 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
814 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
815 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
816 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
817 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
818 |
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
|
819 |
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
|
820 |
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
|
821 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
822 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
823 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
824 |
parent.AddGrowableCol(0) |
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_TopBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
827 |
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
|
828 |
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
|
829 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
830 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
831 |
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
|
832 |
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
|
833 |
parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
276 | 834 |
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
|
835 |
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
|
836 |
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
|
837 |
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
|
838 |
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
|
839 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
840 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
841 |
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
|
842 |
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
|
843 |
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
|
844 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
845 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
846 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
847 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
848 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
849 |
def _init_coll_RightTopGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
850 |
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
|
851 |
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
|
852 |
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
|
853 |
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
|
854 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
855 |
def _init_coll_RightTopGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
856 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
857 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
858 |
def _init_coll_RightBottomGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
859 |
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
|
860 |
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
|
861 |
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
|
862 |
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
|
863 |
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
|
864 |
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
|
865 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
866 |
def _init_coll_RightBottomGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
867 |
parent.AddGrowableCol(0) |
205 | 868 |
|
869 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
870 |
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
|
871 |
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
|
872 |
self.TopBoxSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
873 |
self.LeftBoxSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
874 |
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
|
875 |
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
|
876 |
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
|
877 |
|
205 | 878 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
879 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
880 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
881 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
882 |
self._init_coll_TopBoxSizer_Items(self.TopBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
883 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
884 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
885 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
886 |
self._init_coll_RightTopGridSizer_Items(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
887 |
self._init_coll_RightTopGridSizer_Growables(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
888 |
self._init_coll_RightBottomGridSizer_Items(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
889 |
self._init_coll_RightBottomGridSizer_Growables(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
890 |
|
205 | 891 |
self.SetSizer(self.flexGridSizer1) |
892 |
||
893 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
894 |
wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
205 | 895 |
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
|
896 |
size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
205 | 897 |
title='Create a new Node') |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
898 |
self.SetClientSize(wx.Size(450, 350)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
899 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
900 |
self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
259 | 901 |
label='Type:', name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
902 |
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
|
903 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
904 |
self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
259 | 905 |
label='Name:', name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
906 |
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
|
907 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
908 |
self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
259 | 909 |
label='Node ID:', name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
910 |
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
|
911 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
912 |
self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
913 |
label='Profile:', name='staticText4', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
914 |
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
|
915 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
916 |
self.Type = wx.Choice(choices=[], id=ID_CREATENODEDIALOGTYPE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
917 |
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
|
918 |
size=wx.Size(0, 25), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
919 |
|
276 | 920 |
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
|
921 |
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
|
922 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
923 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
924 |
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
|
925 |
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
|
926 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
927 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
928 |
self.Profile = wx.Choice(choices=[], id=ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
929 |
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
|
930 |
size=wx.Size(0, 24), style=0) |
205 | 931 |
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
|
932 |
id=ID_CREATENODEDIALOGPROFILE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
933 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
934 |
self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
205 | 935 |
label='Network Management:', name='staticText5', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
936 |
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
|
937 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
938 |
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
|
939 |
label='None', name='NMT_None', 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.NMT_None.SetValue(True) |
942 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
943 |
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
|
944 |
label='Node Guarding', name='NMT_NodeGuarding', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
945 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 946 |
self.NMT_NodeGuarding.SetValue(False) |
947 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
948 |
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
|
949 |
label='Heartbeat', name='NMT_Heartbeat', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
950 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 951 |
self.NMT_Heartbeat.SetValue(False) |
952 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
953 |
self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
954 |
label='Options:', name='staticText6', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
955 |
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
|
956 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
957 |
self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
958 |
label='DS-302 Profile', name='DS302', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
959 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 960 |
self.DS302.SetValue(False) |
961 |
#self.DS302.Enable(False) |
|
962 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
963 |
self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
964 |
label='Generate SYNC', name='GenSYNC', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
965 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 966 |
self.GenSYNC.SetValue(False) |
967 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
968 |
self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
205 | 969 |
label='Emergency support', name='Emergency', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
970 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 971 |
self.Emergency.SetValue(False) |
972 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
973 |
self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
974 |
label='Save Configuration', name='SaveConfig', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
975 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 976 |
self.SaveConfig.SetValue(False) |
977 |
self.SaveConfig.Enable(False) |
|
978 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
979 |
self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
980 |
label='Store EDS', name='StoreEDS', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
981 |
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
|
982 |
self.StoreEDS.SetValue(False) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
983 |
self.StoreEDS.Hide() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
984 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
985 |
self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
986 |
label='Description:', name='staticText7', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
987 |
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
|
988 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
989 |
self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
990 |
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
|
991 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
992 |
|
259 | 993 |
self.Spacer = wx.Panel(id=ID_CREATENODEDIALOGSPACER, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
994 |
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
|
995 |
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
|
996 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
997 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
998 |
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
|
999 |
|
205 | 1000 |
self._init_sizers() |
1001 |
||
258 | 1002 |
def __init__(self, parent): |
205 | 1003 |
self._init_ctrls(parent) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1004 |
|
299 | 1005 |
self.staticText3.Hide() |
1006 |
self.NodeID.Hide() |
|
1007 |
||
205 | 1008 |
self.NodeID.SetValue("0x00") |
1009 |
self.Type.Append("master") |
|
1010 |
self.Type.Append("slave") |
|
1011 |
self.Type.SetStringSelection("slave") |
|
1012 |
self.Description.SetValue("") |
|
1013 |
self.ListProfile = {"None" : ""} |
|
1014 |
self.Profile.Append("None") |
|
258 | 1015 |
self.Directory = os.path.join(ScriptDirectory, "config") |
205 | 1016 |
listfiles = os.listdir(self.Directory) |
1017 |
listfiles.sort() |
|
1018 |
for item in listfiles: |
|
1019 |
name, extend = os.path.splitext(item) |
|
1020 |
if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
|
1021 |
self.ListProfile[name] = os.path.join(self.Directory, item) |
|
1022 |
self.Profile.Append(name) |
|
1023 |
self.Profile.Append("Other") |
|
1024 |
self.Profile.SetStringSelection("None") |
|
276 | 1025 |
self.NodeName.SetFocus() |
205 | 1026 |
|
1027 |
def OnOK(self, event): |
|
276 | 1028 |
name = self.NodeName.GetValue() |
205 | 1029 |
message = "" |
1030 |
if name != "": |
|
1031 |
good = not name[0].isdigit() |
|
1032 |
for item in name.split("_"): |
|
1033 |
good &= item.isalnum() |
|
1034 |
if not good: |
|
1035 |
message = "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!" |
|
1036 |
if message != "": |
|
1037 |
try: |
|
1038 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1039 |
except: |
|
1040 |
message = "Node ID must be an integer!" |
|
1041 |
if message != "": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1042 |
message = wx.MessageDialog(self, message, "ERROR", wx.OK|wx.ICON_ERROR) |
205 | 1043 |
message.ShowModal() |
1044 |
message.Destroy() |
|
276 | 1045 |
self.NodeName.SetFocus() |
205 | 1046 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1047 |
self.EndModal(wx.ID_OK) |
205 | 1048 |
|
1049 |
def GetValues(self): |
|
276 | 1050 |
name = self.NodeName.GetValue() |
205 | 1051 |
nodeid = 0 |
1052 |
if self.NodeID.GetValue() != "": |
|
1053 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1054 |
type = self.Type.GetStringSelection() |
|
1055 |
description = self.Description.GetValue() |
|
1056 |
return name, nodeid, type, description |
|
1057 |
||
1058 |
def GetProfile(self): |
|
1059 |
name = self.Profile.GetStringSelection() |
|
1060 |
return name, self.ListProfile[name] |
|
1061 |
||
1062 |
def GetNMTManagement(self): |
|
1063 |
if self.NMT_None.GetValue(): |
|
1064 |
return "None" |
|
1065 |
elif self.NMT_NodeGuarding.GetValue(): |
|
1066 |
return "NodeGuarding" |
|
1067 |
elif self.NMT_Heartbeat.GetValue(): |
|
1068 |
return "Heartbeat" |
|
1069 |
return None |
|
1070 |
||
1071 |
def GetOptions(self): |
|
1072 |
options = [] |
|
1073 |
if self.DS302.GetValue(): |
|
1074 |
options.append("DS302") |
|
1075 |
if self.GenSYNC.GetValue(): |
|
1076 |
options.append("GenSYNC") |
|
1077 |
if self.Emergency.GetValue(): |
|
1078 |
options.append("Emergency") |
|
1079 |
if self.SaveConfig.GetValue(): |
|
1080 |
options.append("SaveConfig") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1081 |
if self.StoreEDS.GetValue(): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1082 |
options.append("StoreEDS") |
205 | 1083 |
return options |
1084 |
||
1085 |
def OnProfileChoice(self, event): |
|
1086 |
if self.Profile.GetStringSelection() == "Other": |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1087 |
dialog = wx.FileDialog(self, "Choose a file", self.Directory, "", "OD Profile files (*.prf)|*.prf|All files|*.*", wx.OPEN|wx.CHANGE_DIR) |
205 | 1088 |
dialog.ShowModal() |
1089 |
filepath = dialog.GetPath() |
|
1090 |
dialog.Destroy() |
|
1091 |
if os.path.isfile(filepath): |
|
1092 |
name = os.path.splitext(os.path.basename(filepath))[0] |
|
1093 |
self.ListProfile[name] = filepath |
|
1094 |
length = self.Profile.GetCount() |
|
1095 |
self.Profile.Insert(name, length - 2) |
|
1096 |
self.Profile.SetStringSelection(name) |
|
1097 |
else: |
|
1098 |
self.Profile.SetStringSelection("None") |
|
1099 |
event.Skip() |
|
1100 |
||
1101 |
||
1102 |
#------------------------------------------------------------------------------- |
|
1103 |
# ADD Slave to NodeList Dialog |
|
1104 |
#------------------------------------------------------------------------------- |
|
1105 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1106 |
[ID_ADDSLAVEDIALOG, ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1107 |
ID_ADDSLAVEDIALOGSLAVENODEID, ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1108 |
ID_ADDSLAVEDIALOGIMPORTEDS, ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1109 |
ID_ADDSLAVEDIALOGSTATICTEXT2, ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1110 |
] = [wx.NewId() for _init_ctrls in range(8)] |
205 | 1111 |
|
1112 |
class AddSlaveDialog(wx.Dialog): |
|
1113 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1114 |
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
|
1115 |
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
|
1116 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1117 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1118 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1119 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1120 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1121 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1122 |
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
|
1123 |
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
|
1124 |
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
|
1125 |
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
|
1126 |
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
|
1127 |
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
|
1128 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1129 |
def _init_coll_BottomSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1130 |
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
|
1131 |
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
|
1132 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1133 |
def _init_coll_BottomSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1134 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1135 |
parent.AddGrowableRow(0) |
205 | 1136 |
|
1137 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1138 |
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
|
1139 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1140 |
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
|
1141 |
|
205 | 1142 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1143 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1144 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1145 |
self._init_coll_BottomSizer_Items(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1146 |
self._init_coll_BottomSizer_Growables(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1147 |
|
205 | 1148 |
self.SetSizer(self.flexGridSizer1) |
1149 |
||
1150 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1151 |
wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
205 | 1152 |
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
|
1153 |
size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
205 | 1154 |
title='Add a slave to nodelist') |
1155 |
self.SetClientSize(wx.Size(300, 250)) |
|
1156 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1157 |
self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1158 |
label='Slave Name:', name='staticText1', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1159 |
pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1160 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1161 |
self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1162 |
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
|
1163 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1164 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1165 |
self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1166 |
label='Slave Node ID:', name='staticText2', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1167 |
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
|
1168 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1169 |
self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1170 |
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
|
1171 |
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
|
1172 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1173 |
self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1174 |
label='EDS File:', name='staticText3', parent=self, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1175 |
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
|
1176 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1177 |
self.EDSFile = wx.Choice(id=ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1178 |
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
|
1179 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1180 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1181 |
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
|
1182 |
name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
205 | 1183 |
size=wx.Size(100, 32), style=0) |
1184 |
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
|
1185 |
id=ID_ADDSLAVEDIALOGIMPORTEDS) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1186 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1187 |
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
|
1188 |
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
|
1189 |
|
205 | 1190 |
self._init_sizers() |
1191 |
||
1192 |
def __init__(self, parent): |
|
1193 |
self._init_ctrls(parent) |
|
1194 |
||
1195 |
self.SlaveNodeID.SetValue("0x00") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1196 |
|
205 | 1197 |
def OnOK(self, event): |
1198 |
error = [] |
|
1199 |
if self.SlaveName.GetValue() == "": |
|
1200 |
error.append("Slave Name") |
|
1201 |
if self.SlaveNodeID.GetValue() == "": |
|
1202 |
error.append("Slave Node ID") |
|
1203 |
if self.EDSFile.GetStringSelection() == "": |
|
1204 |
error.append("EDS File") |
|
1205 |
if len(error) > 0: |
|
1206 |
text = "" |
|
1207 |
for i, item in enumerate(error): |
|
1208 |
if i == 0: |
|
1209 |
text += item |
|
1210 |
elif i == len(error) - 1: |
|
1211 |
text += " and %s"%item |
|
1212 |
else: |
|
1213 |
text += ", %s"%item |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1214 |
message = wx.MessageDialog(self, "Form isn't complete. %s must be filled!"%text, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1215 |
message.ShowModal() |
1216 |
message.Destroy() |
|
1217 |
else: |
|
1218 |
try: |
|
1219 |
nodeid = self.SlaveNodeID.GetValue() |
|
1220 |
if nodeid.find("x") != -1: |
|
1221 |
nodeid = int(nodeid, 16) |
|
1222 |
else: |
|
1223 |
nodeid = int(nodeid) |
|
1224 |
except: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1225 |
message = wx.MessageDialog(self, "Slave Node ID must be a value in decimal or hexadecimal!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1226 |
message.ShowModal() |
1227 |
message.Destroy() |
|
1228 |
return |
|
1229 |
if not 0 <= nodeid <= 127: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1230 |
message = wx.MessageDialog(self, "Slave Node ID must be between 0 and 127!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1231 |
message.ShowModal() |
1232 |
message.Destroy() |
|
1233 |
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
|
1234 |
message = wx.MessageDialog(self, "A Node with this ID already exist in the network!", "Error", wx.OK|wx.ICON_ERROR) |
205 | 1235 |
message.ShowModal() |
1236 |
message.Destroy() |
|
1237 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1238 |
self.EndModal(wx.ID_OK) |
205 | 1239 |
|
1240 |
def OnImportEDSButton(self, event): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1241 |
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
|
1242 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 1243 |
filepath = dialog.GetPath() |
1244 |
if os.path.isfile(filepath): |
|
1245 |
result = self.NodeList.ImportEDSFile(filepath) |
|
1246 |
if result: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1247 |
message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
205 | 1248 |
message.ShowModal() |
1249 |
message.Destroy() |
|
1250 |
dialog.Destroy() |
|
1251 |
self.RefreshEDSFile() |
|
1252 |
event.Skip() |
|
1253 |
||
1254 |
def RefreshEDSFile(self): |
|
1255 |
selection = self.EDSFile.GetStringSelection() |
|
1256 |
self.EDSFile.Clear() |
|
1257 |
for option in self.NodeList.EDSNodes.keys(): |
|
1258 |
self.EDSFile.Append(option) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1259 |
if self.EDSFile.FindString(selection) != wx.NOT_FOUND: |
205 | 1260 |
self.EDSFile.SetStringSelection(selection) |
1261 |
||
1262 |
def SetNodeList(self, nodelist): |
|
1263 |
self.NodeList = nodelist |
|
1264 |
self.RefreshEDSFile() |
|
1265 |
||
1266 |
def GetValues(self): |
|
1267 |
values = {} |
|
1268 |
values["slaveName"] = self.SlaveName.GetValue() |
|
1269 |
nodeid = self.SlaveNodeID.GetValue() |
|
1270 |
if nodeid.find("x") != -1: |
|
1271 |
values["slaveNodeID"] = int(nodeid, 16) |
|
1272 |
else: |
|
1273 |
values["slaveNodeID"] = int(nodeid) |
|
1274 |
values["edsFile"] = self.EDSFile.GetStringSelection() |
|
1275 |
return values |
|
327 | 1276 |
|
1277 |
#------------------------------------------------------------------------------- |
|
1278 |
# Editing DCF Entry Dialog |
|
1279 |
#------------------------------------------------------------------------------- |
|
1280 |
||
1281 |
class DCFEntryValuesTable(wx.grid.PyGridTableBase): |
|
1282 |
||
1283 |
""" |
|
1284 |
A custom wxGrid Table using user supplied data |
|
1285 |
""" |
|
1286 |
def __init__(self, parent, data, colnames): |
|
1287 |
# The base class must be initialized *first* |
|
1288 |
wx.grid.PyGridTableBase.__init__(self) |
|
1289 |
self.data = data |
|
1290 |
self.colnames = colnames |
|
1291 |
self.Parent = parent |
|
1292 |
# XXX |
|
1293 |
# we need to store the row length and collength to |
|
1294 |
# see if the table has changed size |
|
1295 |
self._rows = self.GetNumberRows() |
|
1296 |
self._cols = self.GetNumberCols() |
|
1297 |
||
1298 |
def GetNumberCols(self): |
|
1299 |
return len(self.colnames) |
|
1300 |
||
1301 |
def GetNumberRows(self): |
|
1302 |
return len(self.data) |
|
1303 |
||
1304 |
def GetColLabelValue(self, col): |
|
1305 |
if col < len(self.colnames): |
|
1306 |
return self.colnames[col] |
|
1307 |
||
1308 |
def GetRowLabelValues(self, row): |
|
1309 |
return row |
|
1310 |
||
1311 |
def GetValue(self, row, col): |
|
1312 |
if row < self.GetNumberRows(): |
|
1313 |
return str(self.data[row].get(self.GetColLabelValue(col), "")) |
|
1314 |
||
1315 |
def GetEditor(self, row, col): |
|
1316 |
if row < self.GetNumberRows(): |
|
1317 |
return self.editors[row].get(self.GetColLabelValue(col), "") |
|
1318 |
||
1319 |
def GetValueByName(self, row, colname): |
|
1320 |
return self.data[row].get(colname) |
|
1321 |
||
1322 |
def SetValue(self, row, col, value): |
|
1323 |
if col < len(self.colnames): |
|
1324 |
self.data[row][self.GetColLabelValue(col)] = value |
|
1325 |
||
1326 |
def ResetView(self, grid): |
|
1327 |
""" |
|
1328 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
|
1329 |
update the grid if rows and columns have been added or deleted |
|
1330 |
""" |
|
1331 |
grid.BeginBatch() |
|
1332 |
for current, new, delmsg, addmsg in [ |
|
1333 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
|
1334 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
|
1335 |
]: |
|
1336 |
if new < current: |
|
1337 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
|
1338 |
grid.ProcessTableMessage(msg) |
|
1339 |
elif new > current: |
|
1340 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
|
1341 |
grid.ProcessTableMessage(msg) |
|
1342 |
self.UpdateValues(grid) |
|
1343 |
grid.EndBatch() |
|
1344 |
||
1345 |
self._rows = self.GetNumberRows() |
|
1346 |
self._cols = self.GetNumberCols() |
|
1347 |
# update the column rendering scheme |
|
1348 |
self._updateColAttrs(grid) |
|
1349 |
||
1350 |
# update the scrollbars and the displayed part of the grid |
|
1351 |
grid.AdjustScrollbars() |
|
1352 |
grid.ForceRefresh() |
|
1353 |
||
1354 |
||
1355 |
def UpdateValues(self, grid): |
|
1356 |
"""Update all displayed values""" |
|
1357 |
# This sends an event to the grid table to update all of the values |
|
1358 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
|
1359 |
grid.ProcessTableMessage(msg) |
|
1360 |
||
1361 |
def _updateColAttrs(self, grid): |
|
1362 |
""" |
|
1363 |
wx.grid.Grid -> update the column attributes to add the |
|
1364 |
appropriate renderer given the column name. |
|
1365 |
||
1366 |
Otherwise default to the default renderer. |
|
1367 |
""" |
|
1368 |
||
1369 |
for row in range(self.GetNumberRows()): |
|
1370 |
for col in range(self.GetNumberCols()): |
|
1371 |
editor = wx.grid.GridCellTextEditor() |
|
1372 |
renderer = wx.grid.GridCellStringRenderer() |
|
1373 |
||
1374 |
grid.SetCellEditor(row, col, editor) |
|
1375 |
grid.SetCellRenderer(row, col, renderer) |
|
1376 |
||
1377 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
|
1378 |
||
1379 |
def SetData(self, data): |
|
1380 |
self.data = data |
|
1381 |
||
1382 |
def AppendRow(self, row_content): |
|
1383 |
self.data.append(row_content) |
|
1384 |
||
1385 |
def Empty(self): |
|
1386 |
self.data = [] |
|
1387 |
self.editors = [] |
|
1388 |
||
1389 |
[ID_DCFENTRYVALUESDIALOG, ID_DCFENTRYVALUESDIALOGVALUESGRID, |
|
1390 |
ID_DCFENTRYVALUESDIALOGADDBUTTON, ID_DCFENTRYVALUESDIALOGDELETEBUTTON, |
|
1391 |
ID_DCFENTRYVALUESDIALOGUPBUTTON, ID_DCFENTRYVALUESDIALOGDOWNBUTTON, |
|
1392 |
ID_VARIABLEEDITORPANELSTATICTEXT1, |
|
1393 |
] = [wx.NewId() for _init_ctrls in range(7)] |
|
1394 |
||
1395 |
class DCFEntryValuesDialog(wx.Dialog): |
|
1396 |
||
1397 |
if wx.VERSION < (2, 6, 0): |
|
1398 |
def Bind(self, event, function, id = None): |
|
1399 |
if id is not None: |
|
1400 |
event(self, id, function) |
|
1401 |
else: |
|
1402 |
event(self, function) |
|
1403 |
||
1404 |
def _init_coll_MainSizer_Items(self, parent): |
|
1405 |
parent.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
1406 |
parent.AddWindow(self.ValuesGrid, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
1407 |
parent.AddSizer(self.ButtonPanelSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) |
|
1408 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
1409 |
||
1410 |
def _init_coll_MainSizer_Growables(self, parent): |
|
1411 |
parent.AddGrowableCol(0) |
|
1412 |
parent.AddGrowableRow(1) |
|
1413 |
||
1414 |
def _init_coll_ButtonPanelSizer_Items(self, parent): |
|
1415 |
parent.AddWindow(self.UpButton, 0, border=5, flag=wx.ALL) |
|
1416 |
parent.AddWindow(self.AddButton, 0, border=5, flag=wx.ALL) |
|
1417 |
parent.AddWindow(self.DownButton, 0, border=5, flag=wx.ALL) |
|
1418 |
parent.AddWindow(self.DeleteButton, 0, border=5, flag=wx.ALL) |
|
1419 |
||
1420 |
def _init_sizers(self): |
|
1421 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0) |
|
1422 |
self.ButtonPanelSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
1423 |
||
1424 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
1425 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
1426 |
self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer) |
|
1427 |
||
1428 |
self.SetSizer(self.MainSizer) |
|
1429 |
||
1430 |
def _init_ctrls(self, prnt): |
|
1431 |
wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG, |
|
1432 |
name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1433 |
size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
|
1434 |
title='Edit DCF Entry Values') |
|
1435 |
self.SetClientSize(wx.Size(400, 300)) |
|
1436 |
||
1437 |
self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
|
1438 |
label='Entry Values:', name='staticText1', parent=self, |
|
1439 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
|
1440 |
||
1441 |
self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID, |
|
1442 |
name='ValuesGrid', parent=self, pos=wx.Point(0, 0), |
|
1443 |
size=wx.Size(0, 150), style=wx.VSCROLL) |
|
1444 |
self.ValuesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
|
1445 |
'Sans')) |
|
1446 |
self.ValuesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
1447 |
False, 'Sans')) |
|
1448 |
self.ValuesGrid.SetRowLabelSize(0) |
|
1449 |
self.ValuesGrid.SetSelectionBackground(wx.WHITE) |
|
1450 |
self.ValuesGrid.SetSelectionForeground(wx.BLACK) |
|
1451 |
if wx.VERSION >= (2, 6, 0): |
|
1452 |
self.ValuesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnValuesGridCellChange) |
|
328 | 1453 |
self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell) |
327 | 1454 |
else: |
1455 |
wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange) |
|
328 | 1456 |
wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell) |
327 | 1457 |
|
1458 |
self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label='Add', |
|
1459 |
name='AddButton', parent=self, pos=wx.Point(0, 0), |
|
1460 |
size=wx.Size(72, 32), style=0) |
|
1461 |
self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON) |
|
1462 |
||
1463 |
self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label='Delete', |
|
1464 |
name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
|
1465 |
size=wx.Size(72, 32), style=0) |
|
1466 |
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON) |
|
1467 |
||
1468 |
self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^', |
|
1469 |
name='UpButton', parent=self, pos=wx.Point(0, 0), |
|
1470 |
size=wx.Size(32, 32), style=0) |
|
1471 |
self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_DCFENTRYVALUESDIALOGUPBUTTON) |
|
1472 |
||
1473 |
self.DownButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON, label='v', |
|
1474 |
name='DownButton', parent=self, pos=wx.Point(0, 0), |
|
1475 |
size=wx.Size(32, 32), style=0) |
|
1476 |
self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON) |
|
1477 |
||
1478 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
|
1479 |
||
1480 |
self._init_sizers() |
|
1481 |
||
1482 |
def __init__(self, parent): |
|
1483 |
self._init_ctrls(parent) |
|
1484 |
||
1485 |
self.Values = [] |
|
1486 |
self.DefaultValue = {"Index" : 0, "Subindex" : 0, "Size" : 1, "Value" : 0} |
|
1487 |
||
1488 |
self.Table = DCFEntryValuesTable(self, [], ["Index", "Subindex", "Size", "Value"]) |
|
1489 |
self.ValuesGrid.SetTable(self.Table) |
|
1490 |
||
1491 |
def OnValuesGridCellChange(self, event): |
|
1492 |
row, col = event.GetRow(), event.GetCol() |
|
1493 |
colname = self.Table.GetColLabelValue(col) |
|
1494 |
value = self.Table.GetValue(row, col) |
|
1495 |
try: |
|
1496 |
self.Values[row][colname] = int(value, 16) |
|
1497 |
except: |
|
1498 |
message = wx.MessageDialog(self, "\"%s\" is not a valid value!"%value, "Error", wx.OK|wx.ICON_ERROR) |
|
1499 |
message.ShowModal() |
|
1500 |
message.Destroy() |
|
359
346435b94063
Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents:
328
diff
changeset
|
1501 |
wx.CallAfter(self.RefreshValues) |
346435b94063
Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents:
328
diff
changeset
|
1502 |
event.Skip() |
327 | 1503 |
|
328 | 1504 |
def OnValuesGridSelectCell(self, event): |
1505 |
wx.CallAfter(self.RefreshButtons) |
|
1506 |
event.Skip() |
|
1507 |
||
1508 |
def RefreshButtons(self): |
|
1509 |
row = self.ValuesGrid.GetGridCursorRow() |
|
1510 |
length = len(self.Table.data) |
|
1511 |
self.DeleteButton.Enable(length > 0) |
|
1512 |
self.UpButton.Enable(row > 0) |
|
1513 |
self.DownButton.Enable(row < length - 1) |
|
1514 |
||
327 | 1515 |
def OnAddButton(self, event): |
1516 |
new_row = self.DefaultValue.copy() |
|
1517 |
self.Values.append(new_row) |
|
1518 |
self.RefreshValues() |
|
1519 |
event.Skip() |
|
1520 |
||
1521 |
def OnDeleteButton(self, event): |
|
328 | 1522 |
row = self.ValuesGrid.GetGridCursorRow() |
1523 |
self.Values.pop(row) |
|
327 | 1524 |
self.RefreshValues() |
1525 |
event.Skip() |
|
1526 |
||
1527 |
def OnUpButton(self, event): |
|
1528 |
self.MoveValue(self.ValuesGrid.GetGridCursorRow(), -1) |
|
1529 |
event.Skip() |
|
1530 |
||
1531 |
def OnDownButton(self, event): |
|
1532 |
self.MoveValue(self.ValuesGrid.GetGridCursorRow(), 1) |
|
1533 |
event.Skip() |
|
1534 |
||
1535 |
def MoveValue(self, value_index, move): |
|
1536 |
new_index = max(0, min(value_index + move, len(self.Values) - 1)) |
|
1537 |
if new_index != value_index: |
|
1538 |
self.Values.insert(new_index, self.Values.pop(value_index)) |
|
328 | 1539 |
col = self.ValuesGrid.GetGridCursorCol() |
327 | 1540 |
self.RefreshValues() |
328 | 1541 |
self.ValuesGrid.SetGridCursor(new_index, col) |
1542 |
self.RefreshButtons() |
|
327 | 1543 |
else: |
1544 |
self.RefreshValues() |
|
1545 |
||
1546 |
def SetValues(self, values): |
|
1547 |
self.Values = [] |
|
1548 |
if values != "": |
|
1549 |
data = values[4:] |
|
1550 |
current = 0 |
|
1551 |
for i in xrange(BE_to_LE(values[:4])): |
|
1552 |
value = {} |
|
1553 |
value["Index"] = BE_to_LE(data[current:current+2]) |
|
1554 |
value["Subindex"] = BE_to_LE(data[current+2:current+3]) |
|
1555 |
size = BE_to_LE(data[current+3:current+7]) |
|
1556 |
value["Size"] = size |
|
1557 |
value["Value"] = BE_to_LE(data[current+7:current+7+size]) |
|
1558 |
current += 7 + size |
|
1559 |
self.Values.append(value) |
|
1560 |
self.RefreshValues() |
|
1561 |
||
1562 |
def GetValues(self): |
|
1563 |
value = LE_to_BE(len(self.Values), 4) |
|
1564 |
for row in self.Values: |
|
1565 |
value += LE_to_BE(row["Index"], 2) |
|
1566 |
value += LE_to_BE(row["Subindex"], 1) |
|
1567 |
value += LE_to_BE(row["Size"], 4) |
|
1568 |
value += LE_to_BE(row["Value"], row["Size"]) |
|
1569 |
return value |
|
1570 |
||
1571 |
def RefreshValues(self): |
|
1572 |
if len(self.Table.data) > 0: |
|
328 | 1573 |
self.ValuesGrid.SetGridCursor(0, 0) |
327 | 1574 |
data = [] |
1575 |
for value in self.Values: |
|
1576 |
row = {} |
|
1577 |
row["Index"] = "%04X"%value["Index"] |
|
1578 |
row["Subindex"] = "%02X"%value["Subindex"] |
|
1579 |
row["Size"] = "%08X"%value["Size"] |
|
1580 |
row["Value"] = ("%0"+"%d"%(value["Size"] * 2)+"X")%value["Value"] |
|
1581 |
data.append(row) |
|
1582 |
self.Table.SetData(data) |
|
1583 |
self.Table.ResetView(self.ValuesGrid) |
|
328 | 1584 |
self.RefreshButtons() |
1585 |