changeset 254 | f2b0acb54e65 |
parent 243 | 7fcc129a06ce |
child 258 | 8f7725451453 |
253:bf58ce630b88 | 254:f2b0acb54e65 |
---|---|
19 # |
19 # |
20 #You should have received a copy of the GNU Lesser General Public |
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 |
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 |
22 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
23 |
24 from wxPython.wx import * |
|
25 from wxPython.grid import * |
|
26 import wx |
24 import wx |
27 from wx.lib.anchors import LayoutAnchors |
|
28 import wx.grid |
25 import wx.grid |
29 |
26 |
30 from types import * |
27 from types import * |
31 import os, re, platform, sys, time, traceback, getopt |
28 import os, re, platform, sys, time, traceback, getopt |
32 |
29 |
68 for path in sys.path: |
65 for path in sys.path: |
69 if os.path.isfile(os.path.join(path, "networkedit.py")): |
66 if os.path.isfile(os.path.join(path, "networkedit.py")): |
70 ScriptDirectory = path |
67 ScriptDirectory = path |
71 |
68 |
72 try: |
69 try: |
73 from wxPython.html import * |
70 import wx.html |
74 |
71 |
75 wxEVT_HTML_URL_CLICK = wxNewId() |
72 EVT_HTML_URL_CLICK = wx.NewId() |
76 |
73 |
77 def EVT_HTML_URL_CLICK(win, func): |
74 class HtmlWindowUrlClick(wx.PyEvent): |
78 win.Connect(-1, -1, wxEVT_HTML_URL_CLICK, func) |
|
79 |
|
80 class wxHtmlWindowUrlClick(wxPyEvent): |
|
81 def __init__(self, linkinfo): |
75 def __init__(self, linkinfo): |
82 wxPyEvent.__init__(self) |
76 wx.PyEvent.__init__(self) |
83 self.SetEventType(wxEVT_HTML_URL_CLICK) |
77 self.SetEventType(EVT_HTML_URL_CLICK) |
84 self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget()) |
78 self.linkinfo = (linkinfo.GetHref(), linkinfo.GetTarget()) |
85 |
79 |
86 class wxUrlClickHtmlWindow(wxHtmlWindow): |
80 class UrlClickHtmlWindow(wx.html.HtmlWindow): |
87 """ HTML window that generates and OnLinkClicked event. |
81 """ HTML window that generates and OnLinkClicked event. |
88 |
82 |
89 Use this to avoid having to override HTMLWindow |
83 Use this to avoid having to override HTMLWindow |
90 """ |
84 """ |
91 def OnLinkClicked(self, linkinfo): |
85 def OnLinkClicked(self, linkinfo): |
92 wxPostEvent(self, wxHtmlWindowUrlClick(linkinfo)) |
86 wx.PostEvent(self, HtmlWindowUrlClick(linkinfo)) |
87 |
|
88 def Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY): |
|
89 if event == HtmlWindowUrlClick: |
|
90 self.Connect(-1, -1, EVT_HTML_URL_CLICK, handler) |
|
91 else: |
|
92 wx.html.HtmlWindow.Bind(event, handler, source=source, id=id, id2=id2) |
|
93 |
93 |
94 #------------------------------------------------------------------------------- |
94 #------------------------------------------------------------------------------- |
95 # Html Frame |
95 # Html Frame |
96 #------------------------------------------------------------------------------- |
96 #------------------------------------------------------------------------------- |
97 |
97 |
98 [wxID_HTMLFRAME, wxID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)] |
98 [ID_HTMLFRAME, ID_HTMLFRAMEHTMLCONTENT] = [wx.NewId() for _init_ctrls in range(2)] |
99 |
99 |
100 class HtmlFrame(wx.Frame): |
100 class HtmlFrame(wx.Frame): |
101 def _init_ctrls(self, prnt): |
101 def _init_ctrls(self, prnt): |
102 # generated method, don't edit |
102 # generated method, don't edit |
103 wx.Frame.__init__(self, id=wxID_HTMLFRAME, name='HtmlFrame', |
103 wx.Frame.__init__(self, id=ID_HTMLFRAME, name='HtmlFrame', |
104 parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616), |
104 parent=prnt, pos=wx.Point(320, 231), size=wx.Size(853, 616), |
105 style=wx.DEFAULT_FRAME_STYLE, title='') |
105 style=wx.DEFAULT_FRAME_STYLE, title='') |
106 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_HTMLFRAME) |
106 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_HTMLFRAME) |
107 |
107 |
108 self.HtmlContent = wxUrlClickHtmlWindow(id=wxID_HTMLFRAMEHTMLCONTENT, |
108 self.HtmlContent = UrlClickHtmlWindow(id=ID_HTMLFRAMEHTMLCONTENT, |
109 name='HtmlContent', parent=self, pos=wx.Point(0, 0), |
109 name='HtmlContent', parent=self, pos=wx.Point(0, 0), |
110 size=wx.Size(-1, -1), style=wxHW_SCROLLBAR_AUTO|wxHW_NO_SELECTION) |
110 size=wx.Size(-1, -1), style=wx.html.HW_SCROLLBAR_AUTO|wx.html.HW_NO_SELECTION) |
111 EVT_HTML_URL_CLICK(self.HtmlContent, self.OnLinkClick) |
111 self.HtmlContent.Bind(HtmlWindowUrlClick, self.OnLinkClick) |
112 |
112 |
113 def __init__(self, parent, opened): |
113 def __init__(self, parent, opened): |
114 self._init_ctrls(parent) |
114 self._init_ctrls(parent) |
115 self.HtmlFrameOpened = opened |
115 self.HtmlFrameOpened = opened |
116 |
116 |
127 def OnLinkClick(self, event): |
127 def OnLinkClick(self, event): |
128 url = event.linkinfo[0] |
128 url = event.linkinfo[0] |
129 try: |
129 try: |
130 import webbrowser |
130 import webbrowser |
131 except ImportError: |
131 except ImportError: |
132 wxMessageBox('Please point your browser at: %s' % url) |
132 wx.MessageBox('Please point your browser at: %s' % url) |
133 else: |
133 else: |
134 webbrowser.open(url) |
134 webbrowser.open(url) |
135 |
135 |
136 Html_Window = True |
136 Html_Window = True |
137 except: |
137 except: |
138 Html_Window = False |
138 Html_Window = False |
139 |
139 |
140 |
140 |
141 [wxID_NETWORKEDIT, wxID_NETWORKEDITNETWORKNODES, |
141 [ID_NETWORKEDIT, ID_NETWORKEDITNETWORKNODES, |
142 wxID_NETWORKEDITHELPBAR, |
142 ID_NETWORKEDITHELPBAR, |
143 ] = [wx.NewId() for _init_ctrls in range(3)] |
143 ] = [wx.NewId() for _init_ctrls in range(3)] |
144 |
144 |
145 [wxID_NETWORKEDITADDMENUITEMS0, wxID_NETWORKEDITADDMENUITEMS1, |
145 [ID_NETWORKEDITADDMENUITEMS0, ID_NETWORKEDITADDMENUITEMS1, |
146 wxID_NETWORKEDITADDMENUITEMS2, wxID_NETWORKEDITADDMENUITEMS3, |
146 ID_NETWORKEDITADDMENUITEMS2, ID_NETWORKEDITADDMENUITEMS3, |
147 wxID_NETWORKEDITADDMENUITEMS4, wxID_NETWORKEDITADDMENUITEMS5, |
147 ID_NETWORKEDITADDMENUITEMS4, ID_NETWORKEDITADDMENUITEMS5, |
148 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
148 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
149 |
149 |
150 [wxID_NETWORKEDITFILEMENUITEMS0, wxID_NETWORKEDITFILEMENUITEMS1, |
150 [ID_NETWORKEDITFILEMENUITEMS0, ID_NETWORKEDITFILEMENUITEMS1, |
151 wxID_NETWORKEDITFILEMENUITEMS2, wxID_NETWORKEDITFILEMENUITEMS4, |
151 ID_NETWORKEDITFILEMENUITEMS2, ID_NETWORKEDITFILEMENUITEMS4, |
152 wxID_NETWORKEDITFILEMENUITEMS5, wxID_NETWORKEDITFILEMENUITEMS6, |
152 ID_NETWORKEDITFILEMENUITEMS5, ID_NETWORKEDITFILEMENUITEMS6, |
153 ] = [wx.NewId() for _init_coll_FileMenu_Items in range(6)] |
153 ] = [wx.NewId() for _init_coll_FileMenu_Items in range(6)] |
154 |
154 |
155 [wxID_NETWORKEDITNETWORKMENUITEMS0, wxID_NETWORKEDITNETWORKMENUITEMS1, |
155 [ID_NETWORKEDITNETWORKMENUITEMS0, ID_NETWORKEDITNETWORKMENUITEMS1, |
156 wxID_NETWORKEDITNETWORKMENUITEMS3, |
156 ID_NETWORKEDITNETWORKMENUITEMS3, |
157 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(3)] |
157 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(3)] |
158 |
158 |
159 |
159 |
160 [wxID_NETWORKEDITEDITMENUITEMS0, wxID_NETWORKEDITEDITMENUITEMS1, |
160 [ID_NETWORKEDITEDITMENUITEMS0, ID_NETWORKEDITEDITMENUITEMS1, |
161 wxID_NETWORKEDITEDITMENUITEMS2, wxID_NETWORKEDITEDITMENUITEMS4, |
161 ID_NETWORKEDITEDITMENUITEMS2, ID_NETWORKEDITEDITMENUITEMS4, |
162 wxID_NETWORKEDITEDITMENUITEMS6, wxID_NETWORKEDITEDITMENUITEMS7, |
162 ID_NETWORKEDITEDITMENUITEMS6, ID_NETWORKEDITEDITMENUITEMS7, |
163 wxID_NETWORKEDITEDITMENUITEMS8, |
163 ID_NETWORKEDITEDITMENUITEMS8, |
164 ] = [wx.NewId() for _init_coll_EditMenu_Items in range(7)] |
164 ] = [wx.NewId() for _init_coll_EditMenu_Items in range(7)] |
165 |
165 |
166 [wxID_NETWORKEDITHELPMENUITEMS0, wxID_NETWORKEDITHELPMENUITEMS1, |
166 [ID_NETWORKEDITHELPMENUITEMS0, ID_NETWORKEDITHELPMENUITEMS1, |
167 wxID_NETWORKEDITHELPMENUITEMS2, |
167 ID_NETWORKEDITHELPMENUITEMS2, |
168 ] = [wx.NewId() for _init_coll_HelpMenu_Items in range(3)] |
168 ] = [wx.NewId() for _init_coll_HelpMenu_Items in range(3)] |
169 |
169 |
170 class networkedit(wx.Frame): |
170 class networkedit(wx.Frame): |
171 def _init_coll_menuBar1_Menus(self, parent): |
171 def _init_coll_menuBar1_Menus(self, parent): |
172 # generated method, don't edit |
172 # generated method, don't edit |
179 parent.Append(menu=self.HelpMenu, title='Help') |
179 parent.Append(menu=self.HelpMenu, title='Help') |
180 |
180 |
181 def _init_coll_EditMenu_Items(self, parent): |
181 def _init_coll_EditMenu_Items(self, parent): |
182 # generated method, don't edit |
182 # generated method, don't edit |
183 |
183 |
184 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS4, |
184 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS4, |
185 kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R') |
185 kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R') |
186 parent.AppendSeparator() |
186 parent.AppendSeparator() |
187 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS1, |
187 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS1, |
188 kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z') |
188 kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z') |
189 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS0, |
189 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS0, |
190 kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y') |
190 kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y') |
191 parent.AppendSeparator() |
191 parent.AppendSeparator() |
192 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS6, |
192 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS6, |
193 kind=wx.ITEM_NORMAL, text='Node infos') |
193 kind=wx.ITEM_NORMAL, text='Node infos') |
194 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS2, |
194 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS2, |
195 kind=wx.ITEM_NORMAL, text='DS-301 Profile') |
195 kind=wx.ITEM_NORMAL, text='DS-301 Profile') |
196 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS8, |
196 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS8, |
197 kind=wx.ITEM_NORMAL, text='DS-302 Profile') |
197 kind=wx.ITEM_NORMAL, text='DS-302 Profile') |
198 parent.Append(help='', id=wxID_NETWORKEDITEDITMENUITEMS7, |
198 parent.Append(help='', id=ID_NETWORKEDITEDITMENUITEMS7, |
199 kind=wx.ITEM_NORMAL, text='Other Profile') |
199 kind=wx.ITEM_NORMAL, text='Other Profile') |
200 self.Bind(wx.EVT_MENU, self.OnUndoMenu, |
200 self.Bind(wx.EVT_MENU, self.OnUndoMenu, |
201 id=wxID_NETWORKEDITEDITMENUITEMS1) |
201 id=ID_NETWORKEDITEDITMENUITEMS1) |
202 self.Bind(wx.EVT_MENU, self.OnRedoMenu, |
202 self.Bind(wx.EVT_MENU, self.OnRedoMenu, |
203 id=wxID_NETWORKEDITEDITMENUITEMS0) |
203 id=ID_NETWORKEDITEDITMENUITEMS0) |
204 self.Bind(wx.EVT_MENU, self.OnCommunicationMenu, |
204 self.Bind(wx.EVT_MENU, self.OnCommunicationMenu, |
205 id=wxID_NETWORKEDITEDITMENUITEMS2) |
205 id=ID_NETWORKEDITEDITMENUITEMS2) |
206 self.Bind(wx.EVT_MENU, self.OnRefreshMenu, |
206 self.Bind(wx.EVT_MENU, self.OnRefreshMenu, |
207 id=wxID_NETWORKEDITEDITMENUITEMS4) |
207 id=ID_NETWORKEDITEDITMENUITEMS4) |
208 self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu, |
208 self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu, |
209 id=wxID_NETWORKEDITEDITMENUITEMS6) |
209 id=ID_NETWORKEDITEDITMENUITEMS6) |
210 self.Bind(wx.EVT_MENU, self.OnEditProfileMenu, |
210 self.Bind(wx.EVT_MENU, self.OnEditProfileMenu, |
211 id=wxID_NETWORKEDITEDITMENUITEMS7) |
211 id=ID_NETWORKEDITEDITMENUITEMS7) |
212 self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu, |
212 self.Bind(wx.EVT_MENU, self.OnOtherCommunicationMenu, |
213 id=wxID_NETWORKEDITEDITMENUITEMS8) |
213 id=ID_NETWORKEDITEDITMENUITEMS8) |
214 |
214 |
215 def _init_coll_HelpMenu_Items(self, parent): |
215 def _init_coll_HelpMenu_Items(self, parent): |
216 # generated method, don't edit |
216 # generated method, don't edit |
217 |
217 |
218 parent.Append(help='', id=wxID_NETWORKEDITHELPMENUITEMS0, |
218 parent.Append(help='', id=ID_NETWORKEDITHELPMENUITEMS0, |
219 kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1') |
219 kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1') |
220 self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, |
220 self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, |
221 id=wxID_NETWORKEDITHELPMENUITEMS0) |
221 id=ID_NETWORKEDITHELPMENUITEMS0) |
222 parent.Append(help='', id=wxID_NETWORKEDITHELPMENUITEMS1, |
222 parent.Append(help='', id=ID_NETWORKEDITHELPMENUITEMS1, |
223 kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2') |
223 kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2') |
224 self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, |
224 self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, |
225 id=wxID_NETWORKEDITHELPMENUITEMS1) |
225 id=ID_NETWORKEDITHELPMENUITEMS1) |
226 if Html_Window and self.ModeSolo: |
226 if Html_Window and self.ModeSolo: |
227 parent.Append(help='', id=wxID_NETWORKEDITHELPMENUITEMS2, |
227 parent.Append(help='', id=ID_NETWORKEDITHELPMENUITEMS2, |
228 kind=wx.ITEM_NORMAL, text='About') |
228 kind=wx.ITEM_NORMAL, text='About') |
229 self.Bind(wx.EVT_MENU, self.OnAboutMenu, |
229 self.Bind(wx.EVT_MENU, self.OnAboutMenu, |
230 id=wxID_NETWORKEDITHELPMENUITEMS2) |
230 id=ID_NETWORKEDITHELPMENUITEMS2) |
231 |
231 |
232 def _init_coll_FileMenu_Items(self, parent): |
232 def _init_coll_FileMenu_Items(self, parent): |
233 # generated method, don't edit |
233 # generated method, don't edit |
234 |
234 |
235 parent.Append(help='', id=wxID_NETWORKEDITFILEMENUITEMS5, |
235 parent.Append(help='', id=ID_NETWORKEDITFILEMENUITEMS5, |
236 kind=wx.ITEM_NORMAL, text='New\tCTRL+N') |
236 kind=wx.ITEM_NORMAL, text='New\tCTRL+N') |
237 parent.Append(help='', id=wxID_NETWORKEDITFILEMENUITEMS0, |
237 parent.Append(help='', id=ID_NETWORKEDITFILEMENUITEMS0, |
238 kind=wx.ITEM_NORMAL, text='Open\tCTRL+O') |
238 kind=wx.ITEM_NORMAL, text='Open\tCTRL+O') |
239 parent.Append(help='', id=wxID_NETWORKEDITFILEMENUITEMS1, |
239 parent.Append(help='', id=ID_NETWORKEDITFILEMENUITEMS1, |
240 kind=wx.ITEM_NORMAL, text='Save\tCTRL+S') |
240 kind=wx.ITEM_NORMAL, text='Save\tCTRL+S') |
241 parent.Append(help='', id=wxID_NETWORKEDITFILEMENUITEMS2, |
241 parent.Append(help='', id=ID_NETWORKEDITFILEMENUITEMS2, |
242 kind=wx.ITEM_NORMAL, text='Close\tCTRL+W') |
242 kind=wx.ITEM_NORMAL, text='Close\tCTRL+W') |
243 parent.AppendSeparator() |
243 parent.AppendSeparator() |
244 parent.Append(help='', id=wxID_NETWORKEDITFILEMENUITEMS4, |
244 parent.Append(help='', id=ID_NETWORKEDITFILEMENUITEMS4, |
245 kind=wx.ITEM_NORMAL, text='Exit') |
245 kind=wx.ITEM_NORMAL, text='Exit') |
246 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, |
246 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, |
247 id=wxID_NETWORKEDITFILEMENUITEMS0) |
247 id=ID_NETWORKEDITFILEMENUITEMS0) |
248 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, |
248 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, |
249 id=wxID_NETWORKEDITFILEMENUITEMS1) |
249 id=ID_NETWORKEDITFILEMENUITEMS1) |
250 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, |
250 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, |
251 id=wxID_NETWORKEDITFILEMENUITEMS2) |
251 id=ID_NETWORKEDITFILEMENUITEMS2) |
252 self.Bind(wx.EVT_MENU, self.OnQuitMenu, |
252 self.Bind(wx.EVT_MENU, self.OnQuitMenu, |
253 id=wxID_NETWORKEDITFILEMENUITEMS4) |
253 id=ID_NETWORKEDITFILEMENUITEMS4) |
254 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, |
254 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, |
255 id=wxID_NETWORKEDITFILEMENUITEMS5) |
255 id=ID_NETWORKEDITFILEMENUITEMS5) |
256 |
256 |
257 def _init_coll_NetworkMenu_Items(self, parent): |
257 def _init_coll_NetworkMenu_Items(self, parent): |
258 # generated method, don't edit |
258 # generated method, don't edit |
259 |
259 |
260 parent.Append(help='', id=wxID_NETWORKEDITNETWORKMENUITEMS0, |
260 parent.Append(help='', id=ID_NETWORKEDITNETWORKMENUITEMS0, |
261 kind=wx.ITEM_NORMAL, text='Add Slave Node') |
261 kind=wx.ITEM_NORMAL, text='Add Slave Node') |
262 parent.Append(help='', id=wxID_NETWORKEDITNETWORKMENUITEMS1, |
262 parent.Append(help='', id=ID_NETWORKEDITNETWORKMENUITEMS1, |
263 kind=wx.ITEM_NORMAL, text='Remove Slave Node') |
263 kind=wx.ITEM_NORMAL, text='Remove Slave Node') |
264 parent.AppendSeparator() |
264 parent.AppendSeparator() |
265 parent.Append(help='', id=wxID_NETWORKEDITNETWORKMENUITEMS3, |
265 parent.Append(help='', id=ID_NETWORKEDITNETWORKMENUITEMS3, |
266 kind=wx.ITEM_NORMAL, text='Build Master Dictionary') |
266 kind=wx.ITEM_NORMAL, text='Build Master Dictionary') |
267 self.Bind(wx.EVT_MENU, self.OnAddSlaveMenu, |
267 self.Bind(wx.EVT_MENU, self.OnAddSlaveMenu, |
268 id=wxID_NETWORKEDITNETWORKMENUITEMS0) |
268 id=ID_NETWORKEDITNETWORKMENUITEMS0) |
269 self.Bind(wx.EVT_MENU, self.OnRemoveSlaveMenu, |
269 self.Bind(wx.EVT_MENU, self.OnRemoveSlaveMenu, |
270 id=wxID_NETWORKEDITNETWORKMENUITEMS1) |
270 id=ID_NETWORKEDITNETWORKMENUITEMS1) |
271 ## self.Bind(wx.EVT_MENU, self.OnBuildMasterMenu, |
271 ## self.Bind(wx.EVT_MENU, self.OnBuildMasterMenu, |
272 ## id=wxID_NETWORKEDITNETWORKMENUITEMS3) |
272 ## id=ID_NETWORKEDITNETWORKMENUITEMS3) |
273 |
273 |
274 def _init_coll_AddMenu_Items(self, parent): |
274 def _init_coll_AddMenu_Items(self, parent): |
275 # generated method, don't edit |
275 # generated method, don't edit |
276 |
276 |
277 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS0, |
277 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS0, |
278 kind=wx.ITEM_NORMAL, text='SDO Server') |
278 kind=wx.ITEM_NORMAL, text='SDO Server') |
279 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS1, |
279 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS1, |
280 kind=wx.ITEM_NORMAL, text='SDO Client') |
280 kind=wx.ITEM_NORMAL, text='SDO Client') |
281 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS2, |
281 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS2, |
282 kind=wx.ITEM_NORMAL, text='PDO Transmit') |
282 kind=wx.ITEM_NORMAL, text='PDO Transmit') |
283 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS3, |
283 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS3, |
284 kind=wx.ITEM_NORMAL, text='PDO Receive') |
284 kind=wx.ITEM_NORMAL, text='PDO Receive') |
285 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS4, |
285 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS4, |
286 kind=wx.ITEM_NORMAL, text='Map Variable') |
286 kind=wx.ITEM_NORMAL, text='Map Variable') |
287 parent.Append(help='', id=wxID_NETWORKEDITADDMENUITEMS5, |
287 parent.Append(help='', id=ID_NETWORKEDITADDMENUITEMS5, |
288 kind=wx.ITEM_NORMAL, text='User Type') |
288 kind=wx.ITEM_NORMAL, text='User Type') |
289 self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu, |
289 self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu, |
290 id=wxID_NETWORKEDITADDMENUITEMS0) |
290 id=ID_NETWORKEDITADDMENUITEMS0) |
291 self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu, |
291 self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu, |
292 id=wxID_NETWORKEDITADDMENUITEMS1) |
292 id=ID_NETWORKEDITADDMENUITEMS1) |
293 self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu, |
293 self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu, |
294 id=wxID_NETWORKEDITADDMENUITEMS2) |
294 id=ID_NETWORKEDITADDMENUITEMS2) |
295 self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu, |
295 self.Bind(wx.EVT_MENU, self.OnAddPDOReceiveMenu, |
296 id=wxID_NETWORKEDITADDMENUITEMS3) |
296 id=ID_NETWORKEDITADDMENUITEMS3) |
297 self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu, |
297 self.Bind(wx.EVT_MENU, self.OnAddMapVariableMenu, |
298 id=wxID_NETWORKEDITADDMENUITEMS4) |
298 id=ID_NETWORKEDITADDMENUITEMS4) |
299 self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu, |
299 self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu, |
300 id=wxID_NETWORKEDITADDMENUITEMS5) |
300 id=ID_NETWORKEDITADDMENUITEMS5) |
301 |
301 |
302 def _init_coll_HelpBar_Fields(self, parent): |
302 def _init_coll_HelpBar_Fields(self, parent): |
303 # generated method, don't edit |
303 # generated method, don't edit |
304 parent.SetFieldsCount(3) |
304 parent.SetFieldsCount(3) |
305 |
305 |
314 self.menuBar1 = wx.MenuBar() |
314 self.menuBar1 = wx.MenuBar() |
315 self.menuBar1.SetEvtHandlerEnabled(True) |
315 self.menuBar1.SetEvtHandlerEnabled(True) |
316 |
316 |
317 if self.ModeSolo: |
317 if self.ModeSolo: |
318 self.FileMenu = wx.Menu(title='') |
318 self.FileMenu = wx.Menu(title='') |
319 |
|
320 self.NetworkMenu = wx.Menu(title='') |
319 self.NetworkMenu = wx.Menu(title='') |
321 |
|
322 self.EditMenu = wx.Menu(title='') |
320 self.EditMenu = wx.Menu(title='') |
323 |
|
324 self.AddMenu = wx.Menu(title='') |
321 self.AddMenu = wx.Menu(title='') |
325 |
|
326 self.HelpMenu = wx.Menu(title='') |
322 self.HelpMenu = wx.Menu(title='') |
327 |
323 |
328 self._init_coll_menuBar1_Menus(self.menuBar1) |
324 self._init_coll_menuBar1_Menus(self.menuBar1) |
329 if self.ModeSolo: |
325 if self.ModeSolo: |
330 self._init_coll_FileMenu_Items(self.FileMenu) |
326 self._init_coll_FileMenu_Items(self.FileMenu) |
333 self._init_coll_AddMenu_Items(self.AddMenu) |
329 self._init_coll_AddMenu_Items(self.AddMenu) |
334 self._init_coll_HelpMenu_Items(self.HelpMenu) |
330 self._init_coll_HelpMenu_Items(self.HelpMenu) |
335 |
331 |
336 def _init_ctrls(self, prnt): |
332 def _init_ctrls(self, prnt): |
337 # generated method, don't edit |
333 # generated method, don't edit |
338 wx.Frame.__init__(self, id=wxID_NETWORKEDIT, name='networkedit', |
334 wx.Frame.__init__(self, id=ID_NETWORKEDIT, name='networkedit', |
339 parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700), |
335 parent=prnt, pos=wx.Point(149, 178), size=wx.Size(1000, 700), |
340 style=wx.DEFAULT_FRAME_STYLE, title='Networkedit') |
336 style=wx.DEFAULT_FRAME_STYLE, title='Networkedit') |
341 self._init_utils() |
337 self._init_utils() |
342 self.SetClientSize(wx.Size(1000, 700)) |
338 self.SetClientSize(wx.Size(1000, 700)) |
343 self.SetMenuBar(self.menuBar1) |
339 self.SetMenuBar(self.menuBar1) |
344 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=wxID_NETWORKEDIT) |
340 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame, id=ID_NETWORKEDIT) |
345 |
341 |
346 self.NetworkNodes = wx.Notebook(id=wxID_NETWORKEDITNETWORKNODES, |
342 self.NetworkNodes = wx.Notebook(id=ID_NETWORKEDITNETWORKNODES, |
347 name='NetworkNodes', parent=self, pos=wx.Point(0, 0), |
343 name='NetworkNodes', parent=self, pos=wx.Point(0, 0), |
348 size=wx.Size(0, 0), style=wxNB_LEFT) |
344 size=wx.Size(0, 0), style=wx.NB_LEFT) |
349 self.NetworkNodes.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
345 self.NetworkNodes.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
350 self.OnNodeSelectedChanged, id=wxID_NETWORKEDITNETWORKNODES) |
346 self.OnNodeSelectedChanged, id=ID_NETWORKEDITNETWORKNODES) |
351 |
347 |
352 self.HelpBar = wx.StatusBar(id=wxID_NETWORKEDITHELPBAR, name='HelpBar', |
348 self.HelpBar = wx.StatusBar(id=ID_NETWORKEDITHELPBAR, name='HelpBar', |
353 parent=self, style=wxST_SIZEGRIP) |
349 parent=self, style=wx.ST_SIZEGRIP) |
354 self._init_coll_HelpBar_Fields(self.HelpBar) |
350 self._init_coll_HelpBar_Fields(self.HelpBar) |
355 self.SetStatusBar(self.HelpBar) |
351 self.SetStatusBar(self.HelpBar) |
356 |
352 |
357 def __init__(self, parent, nodelist = None): |
353 def __init__(self, parent, nodelist = None): |
358 self.ModeSolo = nodelist == None |
354 self.ModeSolo = nodelist == None |
457 def OnNewProjectMenu(self, event): |
453 def OnNewProjectMenu(self, event): |
458 if self.NodeList: |
454 if self.NodeList: |
459 defaultpath = os.path.dirname(self.NodeList.GetRoot()) |
455 defaultpath = os.path.dirname(self.NodeList.GetRoot()) |
460 else: |
456 else: |
461 defaultpath = os.getcwd() |
457 defaultpath = os.getcwd() |
462 dialog = wxDirDialog(self , "Choose a project", defaultpath, wxDD_NEW_DIR_BUTTON) |
458 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
463 if dialog.ShowModal() == wxID_OK: |
459 if dialog.ShowModal() == wx.ID_OK: |
464 projectpath = dialog.GetPath() |
460 projectpath = dialog.GetPath() |
465 if os.path.isdir(projectpath) and len(os.listdir(projectpath)) == 0: |
461 if os.path.isdir(projectpath) and len(os.listdir(projectpath)) == 0: |
466 os.mkdir(os.path.join(projectpath, "eds")) |
462 os.mkdir(os.path.join(projectpath, "eds")) |
467 manager = NodeManager(ScriptDirectory) |
463 manager = NodeManager(ScriptDirectory) |
468 nodelist = NodeList(manager) |
464 nodelist = NodeList(manager) |
476 self.RefreshBufferState() |
472 self.RefreshBufferState() |
477 self.RefreshTitle() |
473 self.RefreshTitle() |
478 self.RefreshProfileMenu() |
474 self.RefreshProfileMenu() |
479 self.RefreshMainMenu() |
475 self.RefreshMainMenu() |
480 else: |
476 else: |
481 message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) |
477 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR) |
482 message.ShowModal() |
478 message.ShowModal() |
483 message.Destroy() |
479 message.Destroy() |
484 event.Skip() |
480 event.Skip() |
485 |
481 |
486 def OnOpenProjectMenu(self, event): |
482 def OnOpenProjectMenu(self, event): |
487 if self.NodeList: |
483 if self.NodeList: |
488 defaultpath = os.path.dirname(self.NodeList.GetRoot()) |
484 defaultpath = os.path.dirname(self.NodeList.GetRoot()) |
489 else: |
485 else: |
490 defaultpath = os.getcwd() |
486 defaultpath = os.getcwd() |
491 dialog = wxDirDialog(self , "Choose a project", defaultpath, 0) |
487 dialog = wx.DirDialog(self , "Choose a project", defaultpath, 0) |
492 if dialog.ShowModal() == wxID_OK: |
488 if dialog.ShowModal() == wx.ID_OK: |
493 projectpath = dialog.GetPath() |
489 projectpath = dialog.GetPath() |
494 if os.path.isdir(projectpath): |
490 if os.path.isdir(projectpath): |
495 manager = NodeManager(ScriptDirectory) |
491 manager = NodeManager(ScriptDirectory) |
496 nodelist = NodeList(manager) |
492 nodelist = NodeList(manager) |
497 result = nodelist.LoadProject(projectpath) |
493 result = nodelist.LoadProject(projectpath) |
504 self.RefreshBufferState() |
500 self.RefreshBufferState() |
505 self.RefreshTitle() |
501 self.RefreshTitle() |
506 self.RefreshProfileMenu() |
502 self.RefreshProfileMenu() |
507 self.RefreshMainMenu() |
503 self.RefreshMainMenu() |
508 else: |
504 else: |
509 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
505 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
510 message.ShowModal() |
506 message.ShowModal() |
511 message.Destroy() |
507 message.Destroy() |
512 dialog.Destroy() |
508 dialog.Destroy() |
513 event.Skip() |
509 event.Skip() |
514 |
510 |
515 def OnSaveProjectMenu(self, event): |
511 def OnSaveProjectMenu(self, event): |
516 result = self.NodeList.SaveProject() |
512 result = self.NodeList.SaveProject() |
517 if result: |
513 if result: |
518 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
514 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
519 message.ShowModal() |
515 message.ShowModal() |
520 message.Destroy() |
516 message.Destroy() |
521 event.Skip() |
517 event.Skip() |
522 |
518 |
523 def OnCloseProjectMenu(self, event): |
519 def OnCloseProjectMenu(self, event): |
524 if self.NodeList: |
520 if self.NodeList: |
525 if self.NodeList.HasChanged(): |
521 if self.NodeList.HasChanged(): |
526 dialog = wxMessageDialog(self, "There are changes, do you want to save?", "Close Project", wxYES_NO|wxCANCEL|wxICON_QUESTION) |
522 dialog = wx.MessageDialog(self, "There are changes, do you want to save?", "Close Project", wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
527 answer = dialog.ShowModal() |
523 answer = dialog.ShowModal() |
528 dialog.Destroy() |
524 dialog.Destroy() |
529 if answer == wxID_YES: |
525 if answer == wx.ID_YES: |
530 result = self.NodeList.SaveProject() |
526 result = self.NodeList.SaveProject() |
531 if result: |
527 if result: |
532 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
528 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
533 message.ShowModal() |
529 message.ShowModal() |
534 message.Destroy() |
530 message.Destroy() |
535 elif answer == wxID_NO: |
531 elif answer == wx.ID_NO: |
536 self.NodeList.ForceChanged(False) |
532 self.NodeList.ForceChanged(False) |
537 if not self.NodeList.HasChanged(): |
533 if not self.NodeList.HasChanged(): |
538 self.Manager = None |
534 self.Manager = None |
539 self.NodeList = None |
535 self.NodeList = None |
540 self.RefreshNetworkNodes() |
536 self.RefreshNetworkNodes() |
547 #------------------------------------------------------------------------------- |
543 #------------------------------------------------------------------------------- |
548 |
544 |
549 def OnAddSlaveMenu(self, event): |
545 def OnAddSlaveMenu(self, event): |
550 dialog = AddSlaveDialog(self) |
546 dialog = AddSlaveDialog(self) |
551 dialog.SetNodeList(self.NodeList) |
547 dialog.SetNodeList(self.NodeList) |
552 if dialog.ShowModal() == wxID_OK: |
548 if dialog.ShowModal() == wx.ID_OK: |
553 values = dialog.GetValues() |
549 values = dialog.GetValues() |
554 result = self.NodeList.AddSlaveNode(values["slaveName"], values["slaveNodeID"], values["edsFile"]) |
550 result = self.NodeList.AddSlaveNode(values["slaveName"], values["slaveNodeID"], values["edsFile"]) |
555 if not result: |
551 if not result: |
556 new_editingpanel = EditingPanel(self, self.NodeList, False) |
552 new_editingpanel = EditingPanel(self, self.NodeList, False) |
557 new_editingpanel.SetIndex(values["slaveNodeID"]) |
553 new_editingpanel.SetIndex(values["slaveNodeID"]) |
559 self.NetworkNodes.InsertPage(idx, new_editingpanel, "") |
555 self.NetworkNodes.InsertPage(idx, new_editingpanel, "") |
560 self.NodeList.SetCurrentSelected(idx) |
556 self.NodeList.SetCurrentSelected(idx) |
561 self.NetworkNodes.SetSelection(idx) |
557 self.NetworkNodes.SetSelection(idx) |
562 self.RefreshBufferState() |
558 self.RefreshBufferState() |
563 else: |
559 else: |
564 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
560 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
565 message.ShowModal() |
561 message.ShowModal() |
566 message.Destroy() |
562 message.Destroy() |
567 dialog.Destroy() |
563 dialog.Destroy() |
568 event.Skip() |
564 event.Skip() |
569 |
565 |
570 def OnRemoveSlaveMenu(self, event): |
566 def OnRemoveSlaveMenu(self, event): |
571 slavenames = self.NodeList.GetSlaveNames() |
567 slavenames = self.NodeList.GetSlaveNames() |
572 slaveids = self.NodeList.GetSlaveIDs() |
568 slaveids = self.NodeList.GetSlaveIDs() |
573 dialog = wxSingleChoiceDialog(self, "Choose a slave to remove", "Remove slave", slavenames) |
569 dialog = wx.SingleChoiceDialog(self, "Choose a slave to remove", "Remove slave", slavenames) |
574 if dialog.ShowModal() == wxID_OK: |
570 if dialog.ShowModal() == wx.ID_OK: |
575 choice = dialog.GetSelection() |
571 choice = dialog.GetSelection() |
576 result = self.NodeList.RemoveSlaveNode(slaveids[choice]) |
572 result = self.NodeList.RemoveSlaveNode(slaveids[choice]) |
577 if not result: |
573 if not result: |
578 slaveids.pop(choice) |
574 slaveids.pop(choice) |
579 current = self.NetworkNodes.GetSelection() |
575 current = self.NetworkNodes.GetSelection() |
583 self.NetworkNodes.SetSelection(new_selection) |
579 self.NetworkNodes.SetSelection(new_selection) |
584 if new_selection > 0: |
580 if new_selection > 0: |
585 self.NodeList.SetCurrentSelected(slaveids[new_selection - 1]) |
581 self.NodeList.SetCurrentSelected(slaveids[new_selection - 1]) |
586 self.RefreshBufferState() |
582 self.RefreshBufferState() |
587 else: |
583 else: |
588 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
584 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
589 message.ShowModal() |
585 message.ShowModal() |
590 message.Destroy() |
586 message.Destroy() |
591 event.Skip() |
587 event.Skip() |
592 |
588 |
593 #------------------------------------------------------------------------------- |
589 #------------------------------------------------------------------------------- |
655 for i in xrange(3): |
651 for i in xrange(3): |
656 self.HelpBar.SetStatusText("", i) |
652 self.HelpBar.SetStatusText("", i) |
657 |
653 |
658 def RefreshMainMenu(self): |
654 def RefreshMainMenu(self): |
659 if self.menuBar1: |
655 if self.menuBar1: |
660 self.NetworkMenu.Enable(wxID_NETWORKEDITNETWORKMENUITEMS3, False) |
656 self.NetworkMenu.Enable(ID_NETWORKEDITNETWORKMENUITEMS3, False) |
661 if self.NodeList == None: |
657 if self.NodeList == None: |
662 if self.ModeSolo: |
658 if self.ModeSolo: |
663 self.menuBar1.EnableTop(1, False) |
659 self.menuBar1.EnableTop(1, False) |
664 self.menuBar1.EnableTop(2, False) |
660 self.menuBar1.EnableTop(2, False) |
665 self.menuBar1.EnableTop(3, False) |
661 self.menuBar1.EnableTop(3, False) |
666 if self.FileMenu: |
662 if self.FileMenu: |
667 self.FileMenu.Enable(wxID_NETWORKEDITFILEMENUITEMS1, False) |
663 self.FileMenu.Enable(ID_NETWORKEDITFILEMENUITEMS1, False) |
668 self.FileMenu.Enable(wxID_NETWORKEDITFILEMENUITEMS2, False) |
664 self.FileMenu.Enable(ID_NETWORKEDITFILEMENUITEMS2, False) |
669 else: |
665 else: |
670 self.menuBar1.EnableTop(0, False) |
666 self.menuBar1.EnableTop(0, False) |
671 self.menuBar1.EnableTop(1, False) |
667 self.menuBar1.EnableTop(1, False) |
672 self.menuBar1.EnableTop(2, False) |
668 self.menuBar1.EnableTop(2, False) |
673 else: |
669 else: |
674 if self.ModeSolo: |
670 if self.ModeSolo: |
675 self.menuBar1.EnableTop(1, True) |
671 self.menuBar1.EnableTop(1, True) |
676 if self.FileMenu: |
672 if self.FileMenu: |
677 self.FileMenu.Enable(wxID_NETWORKEDITFILEMENUITEMS1, True) |
673 self.FileMenu.Enable(ID_NETWORKEDITFILEMENUITEMS1, True) |
678 self.FileMenu.Enable(wxID_NETWORKEDITFILEMENUITEMS2, True) |
674 self.FileMenu.Enable(ID_NETWORKEDITFILEMENUITEMS2, True) |
679 if self.NetworkNodes.GetSelection() == 0: |
675 if self.NetworkNodes.GetSelection() == 0: |
680 self.menuBar1.EnableTop(2, True) |
676 self.menuBar1.EnableTop(2, True) |
681 self.menuBar1.EnableTop(3, True) |
677 self.menuBar1.EnableTop(3, True) |
682 else: |
678 else: |
683 self.menuBar1.EnableTop(2, False) |
679 self.menuBar1.EnableTop(2, False) |
692 self.menuBar1.EnableTop(2, False) |
688 self.menuBar1.EnableTop(2, False) |
693 |
689 |
694 def RefreshProfileMenu(self): |
690 def RefreshProfileMenu(self): |
695 if self.EditMenu: |
691 if self.EditMenu: |
696 profile = self.Manager.GetCurrentProfileName() |
692 profile = self.Manager.GetCurrentProfileName() |
697 edititem = self.EditMenu.FindItemById(wxID_NETWORKEDITEDITMENUITEMS7) |
693 edititem = self.EditMenu.FindItemById(ID_NETWORKEDITEDITMENUITEMS7) |
698 if edititem: |
694 if edititem: |
699 length = self.AddMenu.GetMenuItemCount() |
695 length = self.AddMenu.GetMenuItemCount() |
700 for i in xrange(length-6): |
696 for i in xrange(length-6): |
701 additem = self.AddMenu.FindItemByPosition(6) |
697 additem = self.AddMenu.FindItemByPosition(6) |
702 self.AddMenu.Delete(additem.GetId()) |
698 self.AddMenu.Delete(additem.GetId()) |
753 if result: |
749 if result: |
754 find_index = True |
750 find_index = True |
755 index, subIndex = result |
751 index, subIndex = result |
756 result = OpenPDFDocIndex(index, ScriptDirectory) |
752 result = OpenPDFDocIndex(index, ScriptDirectory) |
757 if type(result) == StringType: |
753 if type(result) == StringType: |
758 message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) |
754 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR) |
759 message.ShowModal() |
755 message.ShowModal() |
760 message.Destroy() |
756 message.Destroy() |
761 if not find_index: |
757 if not find_index: |
762 result = OpenPDFDocIndex(None, ScriptDirectory) |
758 result = OpenPDFDocIndex(None, ScriptDirectory) |
763 if type(result) == StringType: |
759 if type(result) == StringType: |
764 message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) |
760 message = wx.MessageDialog(self, result, "ERROR", wx.OK|wx.ICON_ERROR) |
765 message.ShowModal() |
761 message.ShowModal() |
766 message.Destroy() |
762 message.Destroy() |
767 event.Skip() |
763 event.Skip() |
768 |
764 |
769 def OnHelpCANFestivalMenu(self, event): |
765 def OnHelpCANFestivalMenu(self, event): |
808 dialog = CommunicationDialog(self) |
804 dialog = CommunicationDialog(self) |
809 dialog.SetTitle(title) |
805 dialog.SetTitle(title) |
810 dialog.SetIndexDictionary(dictionary) |
806 dialog.SetIndexDictionary(dictionary) |
811 dialog.SetCurrentList(current) |
807 dialog.SetCurrentList(current) |
812 dialog.RefreshLists() |
808 dialog.RefreshLists() |
813 if dialog.ShowModal() == wxID_OK: |
809 if dialog.ShowModal() == wx.ID_OK: |
814 new_profile = dialog.GetCurrentList() |
810 new_profile = dialog.GetCurrentList() |
815 addinglist = [] |
811 addinglist = [] |
816 removinglist = [] |
812 removinglist = [] |
817 for index in new_profile: |
813 for index in new_profile: |
818 if index not in current: |
814 if index not in current: |
833 |
829 |
834 def OnNodeInfosMenu(self, event): |
830 def OnNodeInfosMenu(self, event): |
835 dialog = NodeInfosDialog(self) |
831 dialog = NodeInfosDialog(self) |
836 name, id, type, description = self.Manager.GetCurrentNodeInfos() |
832 name, id, type, description = self.Manager.GetCurrentNodeInfos() |
837 dialog.SetValues(name, id, type, description) |
833 dialog.SetValues(name, id, type, description) |
838 if dialog.ShowModal() == wxID_OK: |
834 if dialog.ShowModal() == wx.ID_OK: |
839 name, id, type, description = dialog.GetValues() |
835 name, id, type, description = dialog.GetValues() |
840 self.Manager.SetCurrentNodeInfos(name, id, type, description) |
836 self.Manager.SetCurrentNodeInfos(name, id, type, description) |
841 self.RefreshBufferState() |
837 self.RefreshBufferState() |
842 self.RefreshProfileMenu() |
838 self.RefreshProfileMenu() |
843 selected = self.NetworkNodes.GetSelection() |
839 selected = self.NetworkNodes.GetSelection() |
854 def AddMapVariable(self): |
850 def AddMapVariable(self): |
855 index = self.Manager.GetCurrentNextMapIndex() |
851 index = self.Manager.GetCurrentNextMapIndex() |
856 if index: |
852 if index: |
857 dialog = MapVariableDialog(self) |
853 dialog = MapVariableDialog(self) |
858 dialog.SetIndex(index) |
854 dialog.SetIndex(index) |
859 if dialog.ShowModal() == wxID_OK: |
855 if dialog.ShowModal() == wx.ID_OK: |
860 index, name, struct, number = dialog.GetValues() |
856 index, name, struct, number = dialog.GetValues() |
861 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number) |
857 result = self.Manager.AddMapVariableToCurrent(index, name, struct, number) |
862 if type(result) != StringType: |
858 if type(result) != StringType: |
863 self.RefreshBufferState() |
859 self.RefreshBufferState() |
864 self.RefreshCurrentIndexList() |
860 self.RefreshCurrentIndexList() |
865 else: |
861 else: |
866 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
862 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
867 message.ShowModal() |
863 message.ShowModal() |
868 message.Destroy() |
864 message.Destroy() |
869 dialog.Destroy() |
865 dialog.Destroy() |
870 else: |
866 else: |
871 message = wxMessageDialog(self, result, "No map variable index left!", wxOK|wxICON_ERROR) |
867 message = wx.MessageDialog(self, result, "No map variable index left!", wx.OK|wx.ICON_ERROR) |
872 message.ShowModal() |
868 message.ShowModal() |
873 message.Destroy() |
869 message.Destroy() |
874 |
870 |
875 def AddUserType(self): |
871 def AddUserType(self): |
876 dialog = UserTypeDialog(self) |
872 dialog = UserTypeDialog(self) |
877 dialog.SetTypeList(self.Manager.GetCustomisableTypes()) |
873 dialog.SetTypeList(self.Manager.GetCustomisableTypes()) |
878 if dialog.ShowModal() == wxID_OK: |
874 if dialog.ShowModal() == wx.ID_OK: |
879 type, min, max, length = dialog.GetValues() |
875 type, min, max, length = dialog.GetValues() |
880 result = self.Manager.AddUserTypeToCurrent(type, min, max, length) |
876 result = self.Manager.AddUserTypeToCurrent(type, min, max, length) |
881 if not IsOfType(result, StringType): |
877 if not IsOfType(result, StringType): |
882 self.RefreshBufferState() |
878 self.RefreshBufferState() |
883 self.RefreshCurrentIndexList() |
879 self.RefreshCurrentIndexList() |
884 else: |
880 else: |
885 message = wxMessageDialog(self, result, "Error", wxOK|wxICON_ERROR) |
881 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
886 message.ShowModal() |
882 message.ShowModal() |
887 message.Destroy() |
883 message.Destroy() |
888 dialog.Destroy() |
884 dialog.Destroy() |
889 |
885 |
890 #------------------------------------------------------------------------------- |
886 #------------------------------------------------------------------------------- |
931 dlg.Destroy() |
927 dlg.Destroy() |
932 |
928 |
933 return res |
929 return res |
934 |
930 |
935 def Display_Error_Dialog(e_value): |
931 def Display_Error_Dialog(e_value): |
936 message = wxMessageDialog(None, str(e_value), "Error", wxOK|wxICON_ERROR) |
932 message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR) |
937 message.ShowModal() |
933 message.ShowModal() |
938 message.Destroy() |
934 message.Destroy() |
939 |
935 |
940 def get_last_traceback(tb): |
936 def get_last_traceback(tb): |
941 while tb.tb_next: |
937 while tb.tb_next: |
947 return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
943 return '\n'.join(['%s%s: %s' % (indent, k, repr(v)[:10000]) for k, v in d.iteritems()]) |
948 |
944 |
949 |
945 |
950 ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
946 ignored_exceptions = [] # a problem with a line in a module is only reported once per session |
951 |
947 |
952 def wxAddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
948 def AddExceptHook(path, app_version='[No version]'):#, ignored_exceptions=[]): |
953 |
949 |
954 def handle_exception(e_type, e_value, e_traceback): |
950 def handle_exception(e_type, e_value, e_traceback): |
955 traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
951 traceback.print_exception(e_type, e_value, e_traceback) # this is very helpful when there's an exception in the rest of this func |
956 last_tb = get_last_traceback(e_traceback) |
952 last_tb = get_last_traceback(e_traceback) |
957 ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
953 ex = (last_tb.tb_frame.f_code.co_filename, last_tb.tb_frame.f_lineno) |
989 |
985 |
990 #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
986 #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args) |
991 sys.excepthook = handle_exception |
987 sys.excepthook = handle_exception |
992 |
988 |
993 if __name__ == '__main__': |
989 if __name__ == '__main__': |
994 app = wxPySimpleApp() |
990 app = wx.PySimpleApp() |
995 wxInitAllImageHandlers() |
991 wx.InitAllImageHandlers() |
996 |
992 |
997 # Install a exception handle for bug reports |
993 # Install a exception handle for bug reports |
998 wxAddExceptHook(os.getcwd(),__version__) |
994 AddExceptHook(os.getcwd(),__version__) |
999 |
995 |
1000 frame = networkedit(None) |
996 frame = networkedit(None) |
1001 |
997 |
1002 frame.Show() |
998 frame.Show() |
1003 app.MainLoop() |
999 app.MainLoop() |