author | Edouard Tisserant |
Mon, 23 Apr 2018 12:32:03 +0200 | |
changeset 805 | 570e3a444023 |
parent 786 | 8dbe0aec4f36 |
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, |
580 | 112 |
title=_('Edit Communication Profile')) |
205 | 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, |
580 | 116 |
label=_('Possible Profile Indexes:'), name='staticText1', |
254
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, |
580 | 140 |
label=_('Current Profile Indexes:'), name='staticText2', |
254
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, |
|
580 | 275 |
title=_('Add Map Variable')) |
205 | 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, |
580 | 279 |
label=_('Index:'), name='staticText1', parent=self, |
254
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, |
580 | 283 |
label=_('Type:'), name='staticText2', parent=self, |
254
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, |
580 | 287 |
label=_('Name:'), name='staticText3', parent=self, |
254
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, |
580 | 291 |
label=_('Number:'), name='staticText4', parent=self, |
254
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, |
543 | 303 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=0) |
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, |
543 | 310 |
pos=wx.Point(0, 0), size=wx.Size(80, 24), style=0) |
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), |
580 | 321 |
size=wx.Size(0, 24), style=0, value=_('Undefined')) |
254
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: |
|
580 | 353 |
error.append(_("Index")) |
205 | 354 |
if self.radioButton2.GetValue() or self.radioButton3.GetValue(): |
355 |
try: |
|
356 |
int(self.Number.GetValue()) |
|
357 |
except: |
|
580 | 358 |
error.append(_("Number")) |
205 | 359 |
if len(error) > 0: |
360 |
text = "" |
|
361 |
for i, item in enumerate(error): |
|
362 |
if i == 0: |
|
363 |
text += item |
|
364 |
elif i == len(error) - 1: |
|
580 | 365 |
text += (" and %s")%item + _(" must be integers!") |
205 | 366 |
else: |
580 | 367 |
text += _(", %s")%item + _(" must be integer!") |
368 |
message = wx.MessageDialog(self, _("Form isn't valid. %s")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
|
205 | 369 |
message.ShowModal() |
370 |
message.Destroy() |
|
371 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
372 |
self.EndModal(wx.ID_OK) |
205 | 373 |
|
374 |
def GetValues(self): |
|
375 |
name = self.IndexName.GetValue() |
|
376 |
index = int(self.Index.GetValue(), 16) |
|
377 |
if self.radioButton1.GetValue(): |
|
378 |
struct = 1 |
|
379 |
number = None |
|
380 |
elif self.radioButton2.GetValue(): |
|
452 | 381 |
struct = 7 |
205 | 382 |
number = int(self.Number.GetValue()) |
383 |
elif self.radioButton3.GetValue(): |
|
452 | 384 |
struct = 3 |
205 | 385 |
number = int(self.Number.GetValue()) |
386 |
return index, name, struct, number |
|
387 |
||
388 |
def OnRadioButton1Click(self, event): |
|
389 |
self.EnableNumberTyping(False) |
|
390 |
event.Skip() |
|
391 |
||
392 |
def OnRadioButton2Click(self, event): |
|
393 |
self.EnableNumberTyping(True) |
|
394 |
event.Skip() |
|
395 |
||
396 |
def OnRadioButton3Click(self, event): |
|
397 |
self.EnableNumberTyping(True) |
|
398 |
event.Skip() |
|
399 |
||
400 |
def EnableNumberTyping(self, enable): |
|
401 |
self.staticText4.Enable(enable) |
|
402 |
self.Number.Enable(enable) |
|
403 |
||
404 |
||
405 |
#------------------------------------------------------------------------------- |
|
406 |
# Create User Type Dialog |
|
407 |
#------------------------------------------------------------------------------- |
|
408 |
||
409 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
410 |
[ID_USERTYPEDIALOG, ID_USERTYPEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
411 |
ID_USERTYPEDIALOGTYPE, ID_USERTYPEDIALOGMAX, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
412 |
ID_USERTYPEDIALOGMIN, ID_USERTYPEDIALOGLENGTH, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
413 |
ID_USERTYPEDIALOGSTATICBOX1, ID_USERTYPEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
414 |
ID_USERTYPEDIALOGSTATICTEXT2, ID_USERTYPEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
415 |
ID_USERTYPEDIALOGSTATICTEXT4, |
205 | 416 |
] = [wx.NewId() for _init_ctrls in range(11)] |
417 |
||
418 |
class UserTypeDialog(wx.Dialog): |
|
419 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
420 |
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
|
421 |
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
|
422 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
423 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
424 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
425 |
parent.AddGrowableRow(0) |
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_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
431 |
def _init_coll_LeftGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
432 |
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
|
433 |
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
|
434 |
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
|
435 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
436 |
def _init_coll_LeftGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
437 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
438 |
parent.AddGrowableRow(2) |
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_RightBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
441 |
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
|
442 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
443 |
def _init_coll_RightBoxGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
444 |
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
|
445 |
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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
451 |
def _init_coll_RightBoxGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
452 |
parent.AddGrowableCol(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
453 |
|
205 | 454 |
def _init_sizers(self): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
455 |
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
|
456 |
self.MainSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
457 |
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
|
458 |
self.RightBoxSizer = wx.StaticBoxSizer(self.staticBox1, wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
459 |
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
|
460 |
|
205 | 461 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
462 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
463 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
464 |
self._init_coll_LeftGridSizer_Items(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
465 |
self._init_coll_LeftGridSizer_Growables(self.LeftGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
466 |
self._init_coll_RightBoxSizer_Items(self.RightBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
467 |
self._init_coll_RightBoxGridSizer_Items(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
468 |
self._init_coll_RightBoxGridSizer_Growables(self.RightBoxGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
469 |
|
205 | 470 |
self.SetSizer(self.flexGridSizer1) |
471 |
||
472 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
473 |
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
|
474 |
parent=prnt, pos=wx.Point(376, 223), size=wx.Size(444, 210), |
580 | 475 |
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
|
476 |
self.SetClientSize(wx.Size(444, 210)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
477 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
478 |
self.staticText1 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT1, |
580 | 479 |
label=_('Type:'), name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
480 |
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
|
481 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
482 |
self.Type = wx.ComboBox(choices=[], id=ID_USERTYPEDIALOGTYPE, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
483 |
name='Type', parent=self, pos=wx.Point(0, 0), |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
484 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
762
4b60a0d313b0
Fix bug with Type selection of Array user defined variables
Laurent Bessard
parents:
757
diff
changeset
|
485 |
self.Type.Bind(wx.wx.EVT_COMBOBOX, self.OnTypeChoice, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
486 |
id=ID_USERTYPEDIALOGTYPE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
487 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
488 |
self.Spacer = wx.Panel(id=ID_MAPVARIABLEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
492 |
self.staticBox1 = wx.StaticBox(id=ID_USERTYPEDIALOGSTATICBOX1, |
580 | 493 |
label=_('Values'), name='staticBox1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
494 |
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
|
495 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
496 |
self.staticText2 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT2, |
580 | 497 |
label=_('Minimum:'), name='staticText2', parent=self, |
254
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(80, 17), 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.Min = wx.TextCtrl(id=ID_USERTYPEDIALOGMIN, name='Min', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
501 |
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
|
502 |
style=wx.TE_RIGHT, value='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.staticText3 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT3, |
580 | 505 |
label=_('Maximum:'), name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
506 |
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
|
507 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
508 |
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
|
509 |
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
|
510 |
style=wx.TE_RIGHT, value='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.staticText4 = wx.StaticText(id=ID_USERTYPEDIALOGSTATICTEXT4, |
580 | 513 |
label=_('Length:'), name='staticText4', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
514 |
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
|
515 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
516 |
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
|
517 |
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
|
518 |
style=wx.TE_RIGHT, value='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.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
521 |
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
|
522 |
|
205 | 523 |
self._init_sizers() |
524 |
||
525 |
def __init__(self, parent): |
|
526 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
527 |
|
205 | 528 |
self.TypeDictionary = {} |
529 |
||
530 |
def OnOK(self, event): |
|
531 |
error = [] |
|
532 |
good = True |
|
580 | 533 |
message = None |
205 | 534 |
name = self.Type.GetStringSelection() |
535 |
if name != "": |
|
536 |
valuetype = self.TypeDictionary[name][1] |
|
537 |
if valuetype == 0: |
|
538 |
try: |
|
539 |
int(self.Min.GetValue(), 16) |
|
540 |
except: |
|
580 | 541 |
error.append(_("Minimum")) |
205 | 542 |
good = False |
543 |
try: |
|
544 |
int(self.Max.GetValue(), 16) |
|
545 |
except: |
|
580 | 546 |
error.append(_("Maximum")) |
205 | 547 |
good = False |
548 |
elif valuetype == 1: |
|
549 |
try: |
|
550 |
int(self.Length.GetValue(), 16) |
|
551 |
except: |
|
580 | 552 |
error.append(_("Length")) |
205 | 553 |
good = False |
554 |
if len(error) > 0: |
|
580 | 555 |
message = "" |
205 | 556 |
for i, item in enumerate(error): |
557 |
if i == 0: |
|
580 | 558 |
message += item |
205 | 559 |
elif i == len(error) - 1: |
580 | 560 |
message += _(" and %s")%item + _(" must be integers!") |
205 | 561 |
else: |
580 | 562 |
message += _(", %s")%item + _(" must be integer!") |
205 | 563 |
else: |
580 | 564 |
message = _("A type must be selected!") |
565 |
if message is not None: |
|
566 |
message = wx.MessageDialog(self, _("Form isn't valid. %s")%(firstmessage,secondmessage), _("Error"), wx.OK|wx.ICON_ERROR) |
|
205 | 567 |
message.ShowModal() |
568 |
message.Destroy() |
|
569 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
570 |
self.EndModal(wx.ID_OK) |
205 | 571 |
|
572 |
def SetValues(self, min = None, max = None, length = None): |
|
573 |
if min != None: |
|
574 |
self.Min.SetValue(str(min)) |
|
575 |
if max != None: |
|
576 |
self.Max.SetValue(str(max)) |
|
577 |
if length != None: |
|
578 |
self.Length.SetValue(str(length)) |
|
579 |
||
580 |
def SetTypeList(self, typedic, type = None): |
|
581 |
self.Type.Clear() |
|
582 |
list = [] |
|
583 |
for index, (name, valuetype) in typedic.iteritems(): |
|
584 |
self.TypeDictionary[name] = (index, valuetype) |
|
585 |
list.append((index, name)) |
|
586 |
list.sort() |
|
587 |
for index, name in list: |
|
588 |
self.Type.Append(name) |
|
589 |
if type != None: |
|
590 |
self.Type.SetStringSelection(typedic[type][0]) |
|
591 |
self.RefreshValues() |
|
592 |
||
593 |
def OnTypeChoice(self, event): |
|
594 |
self.RefreshValues() |
|
595 |
event.Skip() |
|
596 |
||
597 |
def RefreshValues(self): |
|
598 |
name = self.Type.GetStringSelection() |
|
599 |
if name != "": |
|
600 |
valuetype = self.TypeDictionary[name][1] |
|
601 |
if valuetype == 0: |
|
602 |
self.staticText2.Enable(True) |
|
603 |
self.staticText3.Enable(True) |
|
604 |
self.staticText4.Enable(False) |
|
605 |
self.Min.Enable(True) |
|
606 |
self.Max.Enable(True) |
|
607 |
self.Length.Enable(False) |
|
608 |
elif valuetype == 1: |
|
609 |
self.staticText2.Enable(False) |
|
610 |
self.staticText3.Enable(False) |
|
611 |
self.staticText4.Enable(True) |
|
612 |
self.Min.Enable(False) |
|
613 |
self.Max.Enable(False) |
|
614 |
self.Length.Enable(True) |
|
615 |
else: |
|
616 |
self.staticText2.Enable(False) |
|
617 |
self.staticText3.Enable(False) |
|
618 |
self.staticText4.Enable(False) |
|
619 |
self.Min.Enable(False) |
|
620 |
self.Max.Enable(False) |
|
621 |
self.Length.Enable(False) |
|
622 |
||
623 |
def GetValues(self): |
|
624 |
name = self.Type.GetStringSelection() |
|
625 |
type = self.TypeDictionary[name][0] |
|
626 |
min = int(self.Min.GetValue()) |
|
627 |
max = int(self.Max.GetValue()) |
|
628 |
length = int(self.Length.GetValue()) |
|
629 |
return type, min, max, length |
|
630 |
||
631 |
||
632 |
||
633 |
#------------------------------------------------------------------------------- |
|
634 |
# Editing Node Infos Dialog |
|
635 |
#------------------------------------------------------------------------------- |
|
636 |
||
637 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
638 |
[ID_NODEINFOSDIALOG, ID_NODEINFOSDIALOGNAME, |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
639 |
ID_NODEINFOSDIALOGNODEID, ID_NODEINFOSDIALOGTYPE, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
640 |
ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, ID_NODEINFOSDIALOGDESCRIPTION, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
641 |
ID_NODEINFOSDIALOGSTATICTEXT1, ID_NODEINFOSDIALOGSTATICTEXT2, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
642 |
ID_NODEINFOSDIALOGSTATICTEXT3, ID_NODEINFOSDIALOGSTATICTEXT4, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
643 |
ID_NODEINFOSDIALOGSTATICTEXT5, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
644 |
] = [wx.NewId() for _init_ctrls in range(11)] |
205 | 645 |
|
580 | 646 |
def GetNodeTypes(): |
647 |
_ = lambda x : x |
|
648 |
return [_("master"), _("slave")] |
|
649 |
NODE_TYPES_DICT = dict([(_(node_type), node_type) for node_type in GetNodeTypes()]) |
|
650 |
||
205 | 651 |
class NodeInfosDialog(wx.Dialog): |
652 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
653 |
parent.AddSizer(self.MainSizer, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
654 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
655 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
656 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
657 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
658 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
659 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
660 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
661 |
parent.AddWindow(self.staticText1, 0, border=0, flag=wx.GROW) |
276 | 662 |
parent.AddWindow(self.NodeName, 0, border=0, flag=wx.GROW) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
663 |
parent.AddWindow(self.staticText2, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
664 |
parent.AddWindow(self.NodeID, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
665 |
parent.AddWindow(self.staticText3, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
666 |
parent.AddWindow(self.Type, 0, border=0, flag=wx.GROW) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
667 |
parent.AddWindow(self.staticText4, 0, border=0, flag=wx.GROW) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
668 |
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
|
669 |
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
|
670 |
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
|
671 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
672 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
673 |
parent.AddGrowableCol(0) |
205 | 674 |
|
675 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
676 |
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
|
677 |
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
|
678 |
|
205 | 679 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
680 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
681 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
682 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
683 |
|
205 | 684 |
self.SetSizer(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
685 |
|
205 | 686 |
def _init_ctrls(self, prnt): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
687 |
wx.Dialog.__init__(self, id=ID_NODEINFOSDIALOG, |
205 | 688 |
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
|
689 |
size=wx.Size(300, 280), style=wx.DEFAULT_DIALOG_STYLE, |
580 | 690 |
title=_('Node infos')) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
691 |
self.SetClientSize(wx.Size(300, 280)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
692 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
693 |
self.staticText1 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT1, |
580 | 694 |
label=_('Name:'), name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
695 |
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
|
696 |
|
276 | 697 |
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
|
698 |
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
|
699 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
700 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
701 |
self.staticText2 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT2, |
580 | 702 |
label=_('Node ID:'), name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
703 |
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
|
704 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
705 |
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
|
706 |
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
|
707 |
style=wx.TE_RIGHT, value='') |
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.staticText3 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT3, |
580 | 710 |
label=_('Type:'), name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
711 |
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
|
712 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
713 |
self.Type = wx.ComboBox(choices=[], id=ID_NODEINFOSDIALOGTYPE, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
714 |
name='Type', parent=self, pos=wx.Point(0, 0), |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
715 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
254
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.staticText4 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT4, |
580 | 718 |
label=_('Default String Size:'), name='staticText4', parent=self, |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
719 |
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
|
720 |
|
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
721 |
self.DefaultStringSize = wx.SpinCtrl(id=ID_NODEINFOSDIALOGDEFAULTSTRINGSIZE, |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
722 |
name='DefaultStringSize', parent=self, pos=wx.Point(0, 0), |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
723 |
size=wx.Size(0, 25), style=wx.TE_RIGHT) |
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.staticText5 = wx.StaticText(id=ID_NODEINFOSDIALOGSTATICTEXT5, |
580 | 726 |
label=_('Description:'), name='staticText5', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
727 |
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
|
728 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
729 |
self.Description = wx.TextCtrl(id=ID_NODEINFOSDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
730 |
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
|
731 |
size=wx.Size(0, 24), style=0, value='') |
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.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
734 |
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
|
735 |
|
205 | 736 |
self._init_sizers() |
737 |
||
738 |
def __init__(self, parent): |
|
739 |
self._init_ctrls(parent) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
740 |
|
299 | 741 |
self.staticText2.Hide() |
742 |
self.NodeID.Hide() |
|
743 |
||
580 | 744 |
for node_type in GetNodeTypes(): |
745 |
self.Type.Append(_(node_type)) |
|
205 | 746 |
|
747 |
def OnOK(self, event): |
|
276 | 748 |
name = self.NodeName.GetValue() |
205 | 749 |
message = "" |
750 |
if name != "": |
|
751 |
good = not name[0].isdigit() |
|
752 |
for item in name.split("_"): |
|
753 |
good &= item.isalnum() |
|
754 |
if not good: |
|
580 | 755 |
message = _("Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!") |
205 | 756 |
if message != "": |
757 |
try: |
|
758 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
759 |
except: |
|
580 | 760 |
message = _("Node ID must be integer!") |
205 | 761 |
if message != "": |
580 | 762 |
message = wx.MessageDialog(self, message, _("ERROR"), wx.OK|wx.ICON_ERROR) |
205 | 763 |
message.ShowModal() |
764 |
message.Destroy() |
|
276 | 765 |
self.NodeName.SetFocus() |
205 | 766 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
767 |
self.EndModal(wx.ID_OK) |
205 | 768 |
|
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
769 |
def SetValues(self, name, id, type, description, defaultstringsize): |
276 | 770 |
self.NodeName.SetValue(name) |
205 | 771 |
self.NodeID.SetValue("0x%02X"%id) |
580 | 772 |
self.Type.SetStringSelection(_(type)) |
205 | 773 |
self.Description.SetValue(description) |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
774 |
self.DefaultStringSize.SetValue(defaultstringsize) |
205 | 775 |
|
776 |
def GetValues(self): |
|
276 | 777 |
name = self.NodeName.GetValue() |
205 | 778 |
nodeid = int(self.NodeID.GetValue(), 16) |
580 | 779 |
type = NODE_TYPES_DICT[self.Type.GetStringSelection()] |
205 | 780 |
description = self.Description.GetValue() |
418
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
781 |
defaultstringsize = self.DefaultStringSize.GetValue() |
64a8c24b61a5
Problem with String size in C file generated fixed
lbessard
parents:
359
diff
changeset
|
782 |
return name, nodeid, type, description, defaultstringsize |
205 | 783 |
|
784 |
||
785 |
||
786 |
#------------------------------------------------------------------------------- |
|
787 |
# Create New Node Dialog |
|
788 |
#------------------------------------------------------------------------------- |
|
789 |
||
790 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
791 |
[ID_CREATENODEDIALOG, ID_CREATENODEDIALOGEMERGENCY, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
792 |
ID_CREATENODEDIALOGGENSYNC, ID_CREATENODEDIALOGSPACER, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
793 |
ID_CREATENODEDIALOGNAME, ID_CREATENODEDIALOGNMT_HEARTBEAT, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
794 |
ID_CREATENODEDIALOGNMT_NODEGUARDING, ID_CREATENODEDIALOGNMT_NONE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
795 |
ID_CREATENODEDIALOGNODEID, ID_CREATENODEDIALOGPROFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
796 |
ID_CREATENODEDIALOGSAVECONFIG, ID_CREATENODEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
797 |
ID_CREATENODEDIALOGSTATICTEXT2, ID_CREATENODEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
798 |
ID_CREATENODEDIALOGSTATICTEXT4, ID_CREATENODEDIALOGSTATICTEXT5, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
799 |
ID_CREATENODEDIALOGSTATICTEXT6, ID_CREATENODEDIALOGSTATICTEXT7, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
800 |
ID_CREATENODEDIALOGSTOREEDS, ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
801 |
ID_CREATENODEDIALOGTYPE, |
205 | 802 |
] = [wx.NewId() for _init_ctrls in range(21)] |
803 |
||
804 |
class CreateNodeDialog(wx.Dialog): |
|
805 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
806 |
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
|
807 |
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
|
808 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
809 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
810 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
811 |
parent.AddGrowableRow(0) |
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_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
814 |
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
|
815 |
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
|
816 |
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
|
817 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
818 |
def _init_coll_MainSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
819 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
820 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
821 |
def _init_coll_TopBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
822 |
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
|
823 |
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
|
824 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
825 |
def _init_coll_LeftBoxSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
826 |
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
|
827 |
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
|
828 |
parent.AddWindow(self.staticText2, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
276 | 829 |
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
|
830 |
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
|
831 |
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
|
832 |
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
|
833 |
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
|
834 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
835 |
def _init_coll_RightGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
836 |
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
|
837 |
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
|
838 |
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
|
839 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
840 |
def _init_coll_RightGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
841 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
842 |
parent.AddGrowableRow(1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
843 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
844 |
def _init_coll_RightTopGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
845 |
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
|
846 |
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
|
847 |
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
|
848 |
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
|
849 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
850 |
def _init_coll_RightTopGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
851 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
852 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
853 |
def _init_coll_RightBottomGridSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
854 |
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
|
855 |
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
|
856 |
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
|
857 |
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
|
858 |
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
|
859 |
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
|
860 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
861 |
def _init_coll_RightBottomGridSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
862 |
parent.AddGrowableCol(0) |
205 | 863 |
|
864 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
865 |
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
|
866 |
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
|
867 |
self.TopBoxSizer = wx.BoxSizer(wx.HORIZONTAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
868 |
self.LeftBoxSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
869 |
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
|
870 |
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
|
871 |
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
|
872 |
|
205 | 873 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
874 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
875 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
876 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
877 |
self._init_coll_TopBoxSizer_Items(self.TopBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
878 |
self._init_coll_LeftBoxSizer_Items(self.LeftBoxSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
879 |
self._init_coll_RightGridSizer_Items(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
880 |
self._init_coll_RightGridSizer_Growables(self.RightGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
881 |
self._init_coll_RightTopGridSizer_Items(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
882 |
self._init_coll_RightTopGridSizer_Growables(self.RightTopGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
883 |
self._init_coll_RightBottomGridSizer_Items(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
884 |
self._init_coll_RightBottomGridSizer_Growables(self.RightBottomGridSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
885 |
|
205 | 886 |
self.SetSizer(self.flexGridSizer1) |
887 |
||
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
888 |
def _init_ctrls(self, prnt, buttons): |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
889 |
wx.Dialog.__init__(self, id=ID_CREATENODEDIALOG, |
205 | 890 |
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
|
891 |
size=wx.Size(450, 350), style=wx.DEFAULT_DIALOG_STYLE, |
580 | 892 |
title=_('Create a new Node')) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
893 |
self.SetClientSize(wx.Size(450, 350)) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
894 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
895 |
self.staticText1 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT1, |
580 | 896 |
label=_('Type:'), name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
897 |
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
|
898 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
899 |
self.staticText2 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT2, |
580 | 900 |
label=_('Name:'), name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
901 |
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
|
902 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
903 |
self.staticText3 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT3, |
580 | 904 |
label=_('Node ID:'), name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
905 |
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
|
906 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
907 |
self.staticText4 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT4, |
580 | 908 |
label=_('Profile:'), name='staticText4', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
909 |
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
|
910 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
911 |
self.Type = wx.ComboBox(choices=[], id=ID_CREATENODEDIALOGTYPE, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
912 |
name='Type', parent=self, pos=wx.Point(0, 0), |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
913 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
914 |
|
276 | 915 |
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
|
916 |
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
|
917 |
style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
918 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
919 |
self.NodeID = wx.TextCtrl(id=ID_CREATENODEDIALOGNODEID, name='NodeID', |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
920 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
921 |
style=wx.TE_RIGHT, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
922 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
923 |
self.Profile = wx.ComboBox(choices=[], id=ID_CREATENODEDIALOGPROFILE, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
924 |
name='Profile', parent=self, pos=wx.Point(0, 0), |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
925 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
762
4b60a0d313b0
Fix bug with Type selection of Array user defined variables
Laurent Bessard
parents:
757
diff
changeset
|
926 |
self.Profile.Bind(wx.EVT_COMBOBOX, self.OnProfileChoice, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
927 |
id=ID_CREATENODEDIALOGPROFILE) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
928 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
929 |
self.staticText5 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT5, |
580 | 930 |
label=_('Network Management:'), name='staticText5', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
931 |
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
|
932 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
933 |
self.NMT_None = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NONE, |
580 | 934 |
label=_('None'), name='NMT_None', parent=self, |
543 | 935 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=wx.RB_GROUP) |
205 | 936 |
self.NMT_None.SetValue(True) |
937 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
938 |
self.NMT_NodeGuarding = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_NODEGUARDING, |
580 | 939 |
label=_('Node Guarding'), name='NMT_NodeGuarding', parent=self, |
254
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_NodeGuarding.SetValue(False) |
942 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
943 |
self.NMT_Heartbeat = wx.RadioButton(id=ID_CREATENODEDIALOGNMT_HEARTBEAT, |
580 | 944 |
label=_('Heartbeat'), name='NMT_Heartbeat', parent=self, |
254
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_Heartbeat.SetValue(False) |
947 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
948 |
self.staticText6 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT6, |
580 | 949 |
label=_('Options:'), name='staticText6', parent=self, |
254
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, 17), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
951 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
952 |
self.DS302 = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
580 | 953 |
label=_('DS-302 Profile'), name='DS302', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
954 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 955 |
self.DS302.SetValue(False) |
956 |
#self.DS302.Enable(False) |
|
957 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
958 |
self.GenSYNC = wx.CheckBox(id=ID_CREATENODEDIALOGGENSYNC, |
580 | 959 |
label=_('Generate SYNC'), name='GenSYNC', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
960 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 961 |
self.GenSYNC.SetValue(False) |
962 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
963 |
self.Emergency = wx.CheckBox(id=ID_CREATENODEDIALOGEMERGENCY, |
580 | 964 |
label=_('Emergency support'), name='Emergency', |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
965 |
parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 966 |
self.Emergency.SetValue(False) |
967 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
968 |
self.SaveConfig = wx.CheckBox(id=ID_CREATENODEDIALOGSAVECONFIG, |
580 | 969 |
label=_('Save Configuration'), name='SaveConfig', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
970 |
pos=wx.Point(0, 0), size=wx.Size(0, 24), style=0) |
205 | 971 |
self.SaveConfig.SetValue(False) |
972 |
self.SaveConfig.Enable(False) |
|
973 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
974 |
self.StoreEDS = wx.CheckBox(id=ID_CREATENODEDIALOGSTOREEDS, |
580 | 975 |
label=_('Store EDS'), name='StoreEDS', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
976 |
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
|
977 |
self.StoreEDS.SetValue(False) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
978 |
self.StoreEDS.Hide() |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
979 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
980 |
self.staticText7 = wx.StaticText(id=ID_CREATENODEDIALOGSTATICTEXT7, |
580 | 981 |
label=_('Description:'), name='staticText7', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
982 |
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
|
983 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
984 |
self.Description = wx.TextCtrl(id=ID_CREATENODEDIALOGDESCRIPTION, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
985 |
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
|
986 |
size=wx.Size(0, 24), style=0, value='') |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
987 |
|
259 | 988 |
self.Spacer = wx.Panel(id=ID_CREATENODEDIALOGSPACER, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
989 |
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
|
990 |
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
|
991 |
|
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
992 |
self.ButtonSizer = self.CreateButtonSizer(buttons) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
993 |
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
|
994 |
|
205 | 995 |
self._init_sizers() |
996 |
||
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
997 |
def __init__(self, parent,buttons=wx.OK|wx.CANCEL): |
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
998 |
self._init_ctrls(parent,buttons) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
999 |
|
299 | 1000 |
self.staticText3.Hide() |
1001 |
self.NodeID.Hide() |
|
1002 |
||
205 | 1003 |
self.NodeID.SetValue("0x00") |
580 | 1004 |
for node_type in GetNodeTypes(): |
1005 |
self.Type.Append(_(node_type)) |
|
1006 |
self.Type.SetStringSelection(_("slave")) |
|
205 | 1007 |
self.Description.SetValue("") |
1008 |
self.ListProfile = {"None" : ""} |
|
580 | 1009 |
self.Profile.Append(_("None")) |
258 | 1010 |
self.Directory = os.path.join(ScriptDirectory, "config") |
205 | 1011 |
listfiles = os.listdir(self.Directory) |
1012 |
listfiles.sort() |
|
1013 |
for item in listfiles: |
|
1014 |
name, extend = os.path.splitext(item) |
|
1015 |
if os.path.isfile(os.path.join(self.Directory, item)) and extend == ".prf" and name != "DS-302": |
|
1016 |
self.ListProfile[name] = os.path.join(self.Directory, item) |
|
1017 |
self.Profile.Append(name) |
|
580 | 1018 |
self.Profile.Append(_("Other")) |
1019 |
self.Profile.SetStringSelection(_("None")) |
|
276 | 1020 |
self.NodeName.SetFocus() |
205 | 1021 |
|
1022 |
def OnOK(self, event): |
|
276 | 1023 |
name = self.NodeName.GetValue() |
205 | 1024 |
message = "" |
1025 |
if name != "": |
|
1026 |
good = not name[0].isdigit() |
|
1027 |
for item in name.split("_"): |
|
1028 |
good &= item.isalnum() |
|
1029 |
if not good: |
|
580 | 1030 |
message = _("Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!") |
205 | 1031 |
if message != "": |
1032 |
try: |
|
1033 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
1034 |
except: |
|
580 | 1035 |
message = _("Node ID must be integer!") |
205 | 1036 |
if message != "": |
580 | 1037 |
message = wx.MessageDialog(self, message, _("ERROR"), wx.OK|wx.ICON_ERROR) |
205 | 1038 |
message.ShowModal() |
1039 |
message.Destroy() |
|
276 | 1040 |
self.NodeName.SetFocus() |
205 | 1041 |
else: |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1042 |
self.EndModal(wx.ID_OK) |
205 | 1043 |
|
1044 |
def GetValues(self): |
|
276 | 1045 |
name = self.NodeName.GetValue() |
205 | 1046 |
nodeid = 0 |
1047 |
if self.NodeID.GetValue() != "": |
|
1048 |
nodeid = int(self.NodeID.GetValue(), 16) |
|
580 | 1049 |
type = NODE_TYPES_DICT[self.Type.GetStringSelection()] |
205 | 1050 |
description = self.Description.GetValue() |
1051 |
return name, nodeid, type, description |
|
1052 |
||
1053 |
def GetProfile(self): |
|
1054 |
name = self.Profile.GetStringSelection() |
|
580 | 1055 |
if name == _("None"): |
1056 |
name = "None" |
|
205 | 1057 |
return name, self.ListProfile[name] |
1058 |
||
1059 |
def GetNMTManagement(self): |
|
1060 |
if self.NMT_None.GetValue(): |
|
1061 |
return "None" |
|
1062 |
elif self.NMT_NodeGuarding.GetValue(): |
|
1063 |
return "NodeGuarding" |
|
1064 |
elif self.NMT_Heartbeat.GetValue(): |
|
1065 |
return "Heartbeat" |
|
1066 |
return None |
|
1067 |
||
1068 |
def GetOptions(self): |
|
1069 |
options = [] |
|
1070 |
if self.DS302.GetValue(): |
|
1071 |
options.append("DS302") |
|
1072 |
if self.GenSYNC.GetValue(): |
|
1073 |
options.append("GenSYNC") |
|
1074 |
if self.Emergency.GetValue(): |
|
1075 |
options.append("Emergency") |
|
1076 |
if self.SaveConfig.GetValue(): |
|
1077 |
options.append("SaveConfig") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1078 |
if self.StoreEDS.GetValue(): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1079 |
options.append("StoreEDS") |
205 | 1080 |
return options |
1081 |
||
1082 |
def OnProfileChoice(self, event): |
|
580 | 1083 |
if self.Profile.GetStringSelection() == _("Other"): |
1084 |
dialog = wx.FileDialog(self, _("Choose a file"), self.Directory, "", _("OD Profile files (*.prf)|*.prf|All files|*.*"), wx.OPEN|wx.CHANGE_DIR) |
|
205 | 1085 |
dialog.ShowModal() |
1086 |
filepath = dialog.GetPath() |
|
1087 |
dialog.Destroy() |
|
1088 |
if os.path.isfile(filepath): |
|
1089 |
name = os.path.splitext(os.path.basename(filepath))[0] |
|
1090 |
self.ListProfile[name] = filepath |
|
1091 |
length = self.Profile.GetCount() |
|
1092 |
self.Profile.Insert(name, length - 2) |
|
1093 |
self.Profile.SetStringSelection(name) |
|
1094 |
else: |
|
580 | 1095 |
self.Profile.SetStringSelection(_("None")) |
205 | 1096 |
event.Skip() |
1097 |
||
1098 |
||
1099 |
#------------------------------------------------------------------------------- |
|
1100 |
# ADD Slave to NodeList Dialog |
|
1101 |
#------------------------------------------------------------------------------- |
|
1102 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1103 |
[ID_ADDSLAVEDIALOG, ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1104 |
ID_ADDSLAVEDIALOGSLAVENODEID, ID_ADDSLAVEDIALOGEDSFILE, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1105 |
ID_ADDSLAVEDIALOGIMPORTEDS, ID_ADDSLAVEDIALOGSTATICTEXT1, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1106 |
ID_ADDSLAVEDIALOGSTATICTEXT2, ID_ADDSLAVEDIALOGSTATICTEXT3, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1107 |
] = [wx.NewId() for _init_ctrls in range(8)] |
205 | 1108 |
|
1109 |
class AddSlaveDialog(wx.Dialog): |
|
1110 |
def _init_coll_flexGridSizer1_Items(self, parent): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1111 |
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
|
1112 |
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
|
1113 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1114 |
def _init_coll_flexGridSizer1_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1115 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1116 |
parent.AddGrowableRow(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1117 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1118 |
def _init_coll_MainSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1119 |
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
|
1120 |
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
|
1121 |
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
|
1122 |
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
|
1123 |
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
|
1124 |
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
|
1125 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1126 |
def _init_coll_BottomSizer_Items(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1127 |
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
|
1128 |
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
|
1129 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1130 |
def _init_coll_BottomSizer_Growables(self, parent): |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1131 |
parent.AddGrowableCol(0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1132 |
parent.AddGrowableRow(0) |
205 | 1133 |
|
1134 |
def _init_sizers(self): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1135 |
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
|
1136 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1137 |
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
|
1138 |
|
205 | 1139 |
self._init_coll_flexGridSizer1_Items(self.flexGridSizer1) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1140 |
self._init_coll_flexGridSizer1_Growables(self.flexGridSizer1) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1141 |
self._init_coll_MainSizer_Items(self.MainSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1142 |
self._init_coll_BottomSizer_Items(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1143 |
self._init_coll_BottomSizer_Growables(self.BottomSizer) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1144 |
|
205 | 1145 |
self.SetSizer(self.flexGridSizer1) |
1146 |
||
1147 |
def _init_ctrls(self, prnt): |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1148 |
wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG, |
205 | 1149 |
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
|
1150 |
size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
580 | 1151 |
title=_('Add a slave to nodelist')) |
205 | 1152 |
self.SetClientSize(wx.Size(300, 250)) |
1153 |
||
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1154 |
self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1, |
580 | 1155 |
label=_('Slave Name:'), name='staticText1', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1156 |
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
|
1157 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1158 |
self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1159 |
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
|
1160 |
size=wx.Size(0, 24), style=0) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1161 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1162 |
self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2, |
580 | 1163 |
label=_('Slave Node ID:'), name='staticText2', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1164 |
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
|
1165 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1166 |
self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID, |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1167 |
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
|
1168 |
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
|
1169 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1170 |
self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3, |
580 | 1171 |
label=_('EDS File:'), name='staticText3', parent=self, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1172 |
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
|
1173 |
|
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
1174 |
self.EDSFile = wx.ComboBox(id=ID_ADDSLAVEDIALOGEDSFILE, |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1175 |
name='EDSFile', parent=self, pos=wx.Point(0, 0), |
585
d62424ba12bf
Replacing wx.Choice controls by wx.ComboBox controls
laurent
parents:
580
diff
changeset
|
1176 |
size=wx.Size(0, 28), style=wx.CB_READONLY) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1177 |
|
580 | 1178 |
self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label=_('Import EDS'), |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1179 |
name='ImportEDS', parent=self, pos=wx.Point(0, 0), |
205 | 1180 |
size=wx.Size(100, 32), style=0) |
1181 |
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
|
1182 |
id=ID_ADDSLAVEDIALOGIMPORTEDS) |
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1183 |
|
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1184 |
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
|
1185 |
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
|
1186 |
|
205 | 1187 |
self._init_sizers() |
1188 |
||
1189 |
def __init__(self, parent): |
|
1190 |
self._init_ctrls(parent) |
|
1191 |
||
1192 |
self.SlaveNodeID.SetValue("0x00") |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1193 |
|
205 | 1194 |
def OnOK(self, event): |
1195 |
error = [] |
|
1196 |
if self.SlaveName.GetValue() == "": |
|
580 | 1197 |
error.append(_("Slave Name")) |
205 | 1198 |
if self.SlaveNodeID.GetValue() == "": |
580 | 1199 |
error.append(_("Slave Node ID")) |
205 | 1200 |
if self.EDSFile.GetStringSelection() == "": |
580 | 1201 |
error.append(_("EDS File")) |
205 | 1202 |
if len(error) > 0: |
1203 |
text = "" |
|
1204 |
for i, item in enumerate(error): |
|
1205 |
if i == 0: |
|
1206 |
text += item |
|
1207 |
elif i == len(error) - 1: |
|
580 | 1208 |
text += _(" and %s")%item |
205 | 1209 |
else: |
580 | 1210 |
text += _(", %s")%item |
1211 |
message = wx.MessageDialog(self, _("Form isn't complete. %s must be filled!")%text, _("Error"), wx.OK|wx.ICON_ERROR) |
|
205 | 1212 |
message.ShowModal() |
1213 |
message.Destroy() |
|
1214 |
else: |
|
1215 |
try: |
|
1216 |
nodeid = self.SlaveNodeID.GetValue() |
|
1217 |
if nodeid.find("x") != -1: |
|
1218 |
nodeid = int(nodeid, 16) |
|
1219 |
else: |
|
1220 |
nodeid = int(nodeid) |
|
1221 |
except: |
|
580 | 1222 |
message = wx.MessageDialog(self, _("Slave Node ID must be a value in decimal or hexadecimal!"), _("Error"), wx.OK|wx.ICON_ERROR) |
205 | 1223 |
message.ShowModal() |
1224 |
message.Destroy() |
|
1225 |
return |
|
1226 |
if not 0 <= nodeid <= 127: |
|
580 | 1227 |
message = wx.MessageDialog(self, _("Slave Node ID must be between 0 and 127!"), _("Error"), wx.OK|wx.ICON_ERROR) |
205 | 1228 |
message.ShowModal() |
1229 |
message.Destroy() |
|
748
18ed0f3b030a
Fixing networkedit to deal with non-null master nodeid
Laurent Bessard
parents:
740
diff
changeset
|
1230 |
elif nodeid == self.NodeList.GetMasterNodeID() or nodeid in self.NodeList.GetSlaveIDs(): |
580 | 1231 |
message = wx.MessageDialog(self, _("A Node with this ID already exist in the network!"), _("Error"), wx.OK|wx.ICON_ERROR) |
205 | 1232 |
message.ShowModal() |
1233 |
message.Destroy() |
|
1234 |
else: |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1235 |
self.EndModal(wx.ID_OK) |
205 | 1236 |
|
1237 |
def OnImportEDSButton(self, event): |
|
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
1238 |
dialog = wx.FileDialog(self, |
580 | 1239 |
_("Choose an EDS file"), |
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1240 |
os.path.expanduser("~"), |
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
1241 |
"", |
580 | 1242 |
_("EDS files (*.eds)|*.eds|All files|*.*"), |
486
edf526bd34b5
added optional cancel button in node creation dialog (Beremiz)
etisserant
parents:
452
diff
changeset
|
1243 |
wx.OPEN) |
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1244 |
if dialog.ShowModal() == wx.ID_OK: |
205 | 1245 |
filepath = dialog.GetPath() |
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1246 |
else: |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1247 |
filepath = "" |
205 | 1248 |
dialog.Destroy() |
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1249 |
if os.path.isfile(filepath): |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1250 |
result, question = self.NodeList.ImportEDSFile(filepath) |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1251 |
if result is not None and question: |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1252 |
dialog = wx.MessageDialog(self, _("%s\nWould you like to replace it ?")%result, _("Question"), wx.YES_NO|wx.ICON_QUESTION) |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1253 |
if dialog.ShowModal() == wx.ID_YES: |
766
206a90c0d343
Fixed bug when replacing already imported EDS file in NetworkEditor
Laurent Bessard
parents:
762
diff
changeset
|
1254 |
result, question = self.NodeList.ImportEDSFile(filepath, True) |
740
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1255 |
dialog.Destroy() |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1256 |
if result is not None and not question: |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1257 |
dialog = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1258 |
dialog.ShowModal() |
b6646a975f23
Fix bug when importing and loading not well formatted eds files
Laurent Bessard
parents:
585
diff
changeset
|
1259 |
dialog.Destroy() |
205 | 1260 |
self.RefreshEDSFile() |
1261 |
event.Skip() |
|
1262 |
||
1263 |
def RefreshEDSFile(self): |
|
1264 |
selection = self.EDSFile.GetStringSelection() |
|
1265 |
self.EDSFile.Clear() |
|
1266 |
for option in self.NodeList.EDSNodes.keys(): |
|
1267 |
self.EDSFile.Append(option) |
|
254
f2b0acb54e65
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
206
diff
changeset
|
1268 |
if self.EDSFile.FindString(selection) != wx.NOT_FOUND: |
205 | 1269 |
self.EDSFile.SetStringSelection(selection) |
1270 |
||
1271 |
def SetNodeList(self, nodelist): |
|
1272 |
self.NodeList = nodelist |
|
1273 |
self.RefreshEDSFile() |
|
1274 |
||
1275 |
def GetValues(self): |
|
1276 |
values = {} |
|
1277 |
values["slaveName"] = self.SlaveName.GetValue() |
|
1278 |
nodeid = self.SlaveNodeID.GetValue() |
|
1279 |
if nodeid.find("x") != -1: |
|
1280 |
values["slaveNodeID"] = int(nodeid, 16) |
|
1281 |
else: |
|
1282 |
values["slaveNodeID"] = int(nodeid) |
|
1283 |
values["edsFile"] = self.EDSFile.GetStringSelection() |
|
1284 |
return values |
|
327 | 1285 |
|
1286 |
#------------------------------------------------------------------------------- |
|
1287 |
# Editing DCF Entry Dialog |
|
1288 |
#------------------------------------------------------------------------------- |
|
1289 |
||
580 | 1290 |
def DCFEntryTableColnames(): |
1291 |
_ = lambda x : x |
|
1292 |
return [_("Index"), _("Subindex"), _("Size"), _("Value")] |
|
1293 |
||
327 | 1294 |
class DCFEntryValuesTable(wx.grid.PyGridTableBase): |
1295 |
||
1296 |
""" |
|
1297 |
A custom wxGrid Table using user supplied data |
|
1298 |
""" |
|
1299 |
def __init__(self, parent, data, colnames): |
|
1300 |
# The base class must be initialized *first* |
|
1301 |
wx.grid.PyGridTableBase.__init__(self) |
|
1302 |
self.data = data |
|
1303 |
self.colnames = colnames |
|
1304 |
self.Parent = parent |
|
1305 |
# XXX |
|
580 | 1306 |
# we need to store the row length and col length to |
327 | 1307 |
# see if the table has changed size |
1308 |
self._rows = self.GetNumberRows() |
|
1309 |
self._cols = self.GetNumberCols() |
|
1310 |
||
1311 |
def GetNumberCols(self): |
|
1312 |
return len(self.colnames) |
|
1313 |
||
1314 |
def GetNumberRows(self): |
|
1315 |
return len(self.data) |
|
1316 |
||
580 | 1317 |
def GetColLabelValue(self, col, translate=True): |
327 | 1318 |
if col < len(self.colnames): |
580 | 1319 |
if translate: |
1320 |
return _(self.colnames[col]) |
|
327 | 1321 |
return self.colnames[col] |
1322 |
||
580 | 1323 |
def GetRowLabelValues(self, row, translate=True): |
327 | 1324 |
return row |
1325 |
||
1326 |
def GetValue(self, row, col): |
|
1327 |
if row < self.GetNumberRows(): |
|
580 | 1328 |
return str(self.data[row].get(self.GetColLabelValue(col, False), "")) |
327 | 1329 |
|
1330 |
def GetEditor(self, row, col): |
|
1331 |
if row < self.GetNumberRows(): |
|
580 | 1332 |
return self.editors[row].get(self.GetColLabelValue(col, False), "") |
327 | 1333 |
|
1334 |
def GetValueByName(self, row, colname): |
|
1335 |
return self.data[row].get(colname) |
|
1336 |
||
1337 |
def SetValue(self, row, col, value): |
|
1338 |
if col < len(self.colnames): |
|
580 | 1339 |
self.data[row][self.GetColLabelValue(col, False)] = value |
327 | 1340 |
|
1341 |
def ResetView(self, grid): |
|
1342 |
""" |
|
1343 |
(wx.grid.Grid) -> Reset the grid view. Call this to |
|
1344 |
update the grid if rows and columns have been added or deleted |
|
1345 |
""" |
|
1346 |
grid.BeginBatch() |
|
1347 |
for current, new, delmsg, addmsg in [ |
|
1348 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
|
1349 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
|
1350 |
]: |
|
1351 |
if new < current: |
|
1352 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
|
1353 |
grid.ProcessTableMessage(msg) |
|
1354 |
elif new > current: |
|
1355 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
|
1356 |
grid.ProcessTableMessage(msg) |
|
1357 |
self.UpdateValues(grid) |
|
1358 |
grid.EndBatch() |
|
1359 |
||
1360 |
self._rows = self.GetNumberRows() |
|
1361 |
self._cols = self.GetNumberCols() |
|
1362 |
# update the column rendering scheme |
|
1363 |
self._updateColAttrs(grid) |
|
1364 |
||
1365 |
# update the scrollbars and the displayed part of the grid |
|
1366 |
grid.AdjustScrollbars() |
|
1367 |
grid.ForceRefresh() |
|
1368 |
||
1369 |
||
1370 |
def UpdateValues(self, grid): |
|
1371 |
"""Update all displayed values""" |
|
1372 |
# This sends an event to the grid table to update all of the values |
|
1373 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
|
1374 |
grid.ProcessTableMessage(msg) |
|
1375 |
||
1376 |
def _updateColAttrs(self, grid): |
|
1377 |
""" |
|
1378 |
wx.grid.Grid -> update the column attributes to add the |
|
1379 |
appropriate renderer given the column name. |
|
1380 |
||
1381 |
Otherwise default to the default renderer. |
|
1382 |
""" |
|
1383 |
||
1384 |
for row in range(self.GetNumberRows()): |
|
1385 |
for col in range(self.GetNumberCols()): |
|
1386 |
editor = wx.grid.GridCellTextEditor() |
|
1387 |
renderer = wx.grid.GridCellStringRenderer() |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1388 |
|
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1389 |
grid.SetReadOnly(row, col, self.Parent.Editable) |
327 | 1390 |
grid.SetCellEditor(row, col, editor) |
1391 |
grid.SetCellRenderer(row, col, renderer) |
|
1392 |
||
1393 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
|
1394 |
||
1395 |
def SetData(self, data): |
|
1396 |
self.data = data |
|
1397 |
||
1398 |
def AppendRow(self, row_content): |
|
1399 |
self.data.append(row_content) |
|
1400 |
||
1401 |
def Empty(self): |
|
1402 |
self.data = [] |
|
1403 |
self.editors = [] |
|
1404 |
||
1405 |
[ID_DCFENTRYVALUESDIALOG, ID_DCFENTRYVALUESDIALOGVALUESGRID, |
|
1406 |
ID_DCFENTRYVALUESDIALOGADDBUTTON, ID_DCFENTRYVALUESDIALOGDELETEBUTTON, |
|
1407 |
ID_DCFENTRYVALUESDIALOGUPBUTTON, ID_DCFENTRYVALUESDIALOGDOWNBUTTON, |
|
1408 |
ID_VARIABLEEDITORPANELSTATICTEXT1, |
|
1409 |
] = [wx.NewId() for _init_ctrls in range(7)] |
|
1410 |
||
1411 |
class DCFEntryValuesDialog(wx.Dialog): |
|
1412 |
||
1413 |
if wx.VERSION < (2, 6, 0): |
|
1414 |
def Bind(self, event, function, id = None): |
|
1415 |
if id is not None: |
|
1416 |
event(self, id, function) |
|
1417 |
else: |
|
1418 |
event(self, function) |
|
1419 |
||
1420 |
def _init_coll_MainSizer_Items(self, parent): |
|
1421 |
parent.AddWindow(self.staticText1, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
1422 |
parent.AddWindow(self.ValuesGrid, 0, border=20, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT) |
|
1423 |
parent.AddSizer(self.ButtonPanelSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT) |
|
1424 |
parent.AddSizer(self.ButtonSizer, 0, border=20, flag=wx.ALIGN_RIGHT|wx.BOTTOM|wx.LEFT|wx.RIGHT) |
|
1425 |
||
1426 |
def _init_coll_MainSizer_Growables(self, parent): |
|
1427 |
parent.AddGrowableCol(0) |
|
1428 |
parent.AddGrowableRow(1) |
|
1429 |
||
1430 |
def _init_coll_ButtonPanelSizer_Items(self, parent): |
|
1431 |
parent.AddWindow(self.UpButton, 0, border=5, flag=wx.ALL) |
|
1432 |
parent.AddWindow(self.AddButton, 0, border=5, flag=wx.ALL) |
|
1433 |
parent.AddWindow(self.DownButton, 0, border=5, flag=wx.ALL) |
|
1434 |
parent.AddWindow(self.DeleteButton, 0, border=5, flag=wx.ALL) |
|
1435 |
||
1436 |
def _init_sizers(self): |
|
1437 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=3, vgap=0) |
|
1438 |
self.ButtonPanelSizer = wx.BoxSizer(wx.HORIZONTAL) |
|
1439 |
||
1440 |
self._init_coll_MainSizer_Items(self.MainSizer) |
|
1441 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
|
1442 |
self._init_coll_ButtonPanelSizer_Items(self.ButtonPanelSizer) |
|
1443 |
||
1444 |
self.SetSizer(self.MainSizer) |
|
1445 |
||
1446 |
def _init_ctrls(self, prnt): |
|
1447 |
wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG, |
|
1448 |
name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223), |
|
1449 |
size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, |
|
580 | 1450 |
title=_('Edit DCF Entry Values')) |
327 | 1451 |
self.SetClientSize(wx.Size(400, 300)) |
1452 |
||
1453 |
self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, |
|
580 | 1454 |
label=_('Entry Values:'), name='staticText1', parent=self, |
327 | 1455 |
pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) |
1456 |
||
1457 |
self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID, |
|
1458 |
name='ValuesGrid', parent=self, pos=wx.Point(0, 0), |
|
1459 |
size=wx.Size(0, 150), style=wx.VSCROLL) |
|
1460 |
self.ValuesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
|
1461 |
'Sans')) |
|
1462 |
self.ValuesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
|
1463 |
False, 'Sans')) |
|
1464 |
self.ValuesGrid.SetRowLabelSize(0) |
|
1465 |
self.ValuesGrid.SetSelectionBackground(wx.WHITE) |
|
1466 |
self.ValuesGrid.SetSelectionForeground(wx.BLACK) |
|
1467 |
if wx.VERSION >= (2, 6, 0): |
|
1468 |
self.ValuesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnValuesGridCellChange) |
|
328 | 1469 |
self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell) |
327 | 1470 |
else: |
1471 |
wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange) |
|
328 | 1472 |
wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell) |
327 | 1473 |
|
580 | 1474 |
self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label=_('Add'), |
327 | 1475 |
name='AddButton', parent=self, pos=wx.Point(0, 0), |
1476 |
size=wx.Size(72, 32), style=0) |
|
1477 |
self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON) |
|
1478 |
||
580 | 1479 |
self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label=_('Delete'), |
327 | 1480 |
name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
1481 |
size=wx.Size(72, 32), style=0) |
|
1482 |
self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON) |
|
1483 |
||
1484 |
self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^', |
|
1485 |
name='UpButton', parent=self, pos=wx.Point(0, 0), |
|
1486 |
size=wx.Size(32, 32), style=0) |
|
1487 |
self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_DCFENTRYVALUESDIALOGUPBUTTON) |
|
1488 |
||
1489 |
self.DownButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON, label='v', |
|
1490 |
name='DownButton', parent=self, pos=wx.Point(0, 0), |
|
1491 |
size=wx.Size(32, 32), style=0) |
|
1492 |
self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON) |
|
1493 |
||
1494 |
self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE) |
|
1495 |
||
1496 |
self._init_sizers() |
|
1497 |
||
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1498 |
def __init__(self, parent, editable=True): |
327 | 1499 |
self._init_ctrls(parent) |
1500 |
||
1501 |
self.Values = [] |
|
1502 |
self.DefaultValue = {"Index" : 0, "Subindex" : 0, "Size" : 1, "Value" : 0} |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1503 |
self.Editable = editable |
327 | 1504 |
|
580 | 1505 |
self.Table = DCFEntryValuesTable(self, [], DCFEntryTableColnames()) |
327 | 1506 |
self.ValuesGrid.SetTable(self.Table) |
1507 |
||
1508 |
def OnValuesGridCellChange(self, event): |
|
1509 |
row, col = event.GetRow(), event.GetCol() |
|
1510 |
colname = self.Table.GetColLabelValue(col) |
|
1511 |
value = self.Table.GetValue(row, col) |
|
1512 |
try: |
|
1513 |
self.Values[row][colname] = int(value, 16) |
|
1514 |
except: |
|
580 | 1515 |
message = wx.MessageDialog(self, _("\"%s\" is not a valid value!")%value, _("Error"), wx.OK|wx.ICON_ERROR) |
327 | 1516 |
message.ShowModal() |
1517 |
message.Destroy() |
|
359
346435b94063
Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents:
328
diff
changeset
|
1518 |
wx.CallAfter(self.RefreshValues) |
346435b94063
Bug on try, except, finally statement with python 2.4 fixed
lbessard
parents:
328
diff
changeset
|
1519 |
event.Skip() |
327 | 1520 |
|
328 | 1521 |
def OnValuesGridSelectCell(self, event): |
1522 |
wx.CallAfter(self.RefreshButtons) |
|
1523 |
event.Skip() |
|
1524 |
||
1525 |
def RefreshButtons(self): |
|
1526 |
row = self.ValuesGrid.GetGridCursorRow() |
|
1527 |
length = len(self.Table.data) |
|
757
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1528 |
self.AddButton.Enable(self.Editable) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1529 |
self.DeleteButton.Enable(self.Editable and length > 0) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1530 |
self.UpButton.Enable(self.Editable and row > 0) |
8150518de469
Fix bug when using not editable EditingPanel for displaying nodelist generated master
Laurent Bessard
parents:
748
diff
changeset
|
1531 |
self.DownButton.Enable(self.Editable and row < length - 1) |
328 | 1532 |
|
327 | 1533 |
def OnAddButton(self, event): |
1534 |
new_row = self.DefaultValue.copy() |
|
1535 |
self.Values.append(new_row) |
|
1536 |
self.RefreshValues() |
|
1537 |
event.Skip() |
|
1538 |
||
1539 |
def OnDeleteButton(self, event): |
|
328 | 1540 |
row = self.ValuesGrid.GetGridCursorRow() |
1541 |
self.Values.pop(row) |
|
327 | 1542 |
self.RefreshValues() |
1543 |
event.Skip() |
|
1544 |
||
1545 |
def OnUpButton(self, event): |
|
1546 |
self.MoveValue(self.ValuesGrid.GetGridCursorRow(), -1) |
|
1547 |
event.Skip() |
|
1548 |
||
1549 |
def OnDownButton(self, event): |
|
1550 |
self.MoveValue(self.ValuesGrid.GetGridCursorRow(), 1) |
|
1551 |
event.Skip() |
|
1552 |
||
1553 |
def MoveValue(self, value_index, move): |
|
1554 |
new_index = max(0, min(value_index + move, len(self.Values) - 1)) |
|
1555 |
if new_index != value_index: |
|
1556 |
self.Values.insert(new_index, self.Values.pop(value_index)) |
|
328 | 1557 |
col = self.ValuesGrid.GetGridCursorCol() |
327 | 1558 |
self.RefreshValues() |
328 | 1559 |
self.ValuesGrid.SetGridCursor(new_index, col) |
1560 |
self.RefreshButtons() |
|
327 | 1561 |
else: |
1562 |
self.RefreshValues() |
|
1563 |
||
1564 |
def SetValues(self, values): |
|
1565 |
self.Values = [] |
|
1566 |
if values != "": |
|
1567 |
data = values[4:] |
|
1568 |
current = 0 |
|
1569 |
for i in xrange(BE_to_LE(values[:4])): |
|
1570 |
value = {} |
|
1571 |
value["Index"] = BE_to_LE(data[current:current+2]) |
|
1572 |
value["Subindex"] = BE_to_LE(data[current+2:current+3]) |
|
1573 |
size = BE_to_LE(data[current+3:current+7]) |
|
1574 |
value["Size"] = size |
|
1575 |
value["Value"] = BE_to_LE(data[current+7:current+7+size]) |
|
1576 |
current += 7 + size |
|
1577 |
self.Values.append(value) |
|
1578 |
self.RefreshValues() |
|
1579 |
||
1580 |
def GetValues(self): |
|
500
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1581 |
if len(self.Values) > 0: |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1582 |
value = LE_to_BE(len(self.Values), 4) |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1583 |
for row in self.Values: |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1584 |
value += LE_to_BE(row["Index"], 2) |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1585 |
value += LE_to_BE(row["Subindex"], 1) |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1586 |
value += LE_to_BE(row["Size"], 4) |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1587 |
value += LE_to_BE(row["Value"], row["Size"]) |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1588 |
return value |
13fcb9328a02
Bug on Concise DCF edit dialog value generating fixed
lbessard
parents:
486
diff
changeset
|
1589 |
return "" |
327 | 1590 |
|
1591 |
def RefreshValues(self): |
|
1592 |
if len(self.Table.data) > 0: |
|
328 | 1593 |
self.ValuesGrid.SetGridCursor(0, 0) |
327 | 1594 |
data = [] |
1595 |
for value in self.Values: |
|
1596 |
row = {} |
|
1597 |
row["Index"] = "%04X"%value["Index"] |
|
1598 |
row["Subindex"] = "%02X"%value["Subindex"] |
|
1599 |
row["Size"] = "%08X"%value["Size"] |
|
1600 |
row["Value"] = ("%0"+"%d"%(value["Size"] * 2)+"X")%value["Value"] |
|
1601 |
data.append(row) |
|
1602 |
self.Table.SetData(data) |
|
1603 |
self.Table.ResetView(self.ValuesGrid) |
|
328 | 1604 |
self.RefreshButtons() |
1605 |