347 return icon |
347 return icon |
348 |
348 |
349 def OnTaskBarStartPLC(self, evt): |
349 def OnTaskBarStartPLC(self, evt): |
350 if self.pyroserver.plcobj is not None: |
350 if self.pyroserver.plcobj is not None: |
351 self.pyroserver.plcobj.StartPLC() |
351 self.pyroserver.plcobj.StartPLC() |
352 evt.Skip() |
|
353 |
352 |
354 def OnTaskBarStopPLC(self, evt): |
353 def OnTaskBarStopPLC(self, evt): |
355 if self.pyroserver.plcobj is not None: |
354 if self.pyroserver.plcobj is not None: |
356 Thread(target=self.pyroserver.plcobj.StopPLC).start() |
355 Thread(target=self.pyroserver.plcobj.StopPLC).start() |
357 evt.Skip() |
|
358 |
356 |
359 def OnTaskBarChangeInterface(self, evt): |
357 def OnTaskBarChangeInterface(self, evt): |
360 dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip_addr) |
358 dlg = ParamsEntryDialog(None, _("Enter the IP of the interface to bind"), defaultValue=self.pyroserver.ip_addr) |
361 dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")), |
359 dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, _("IP is not valid!")), |
362 ( lambda x :len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!")) |
360 ( lambda x :len([x for x in x.split(".") if 0 <= int(x) <= 255]) == 4, _("IP is not valid!")) |
363 ]) |
361 ]) |
364 if dlg.ShowModal() == wx.ID_OK: |
362 if dlg.ShowModal() == wx.ID_OK: |
365 self.pyroserver.ip_addr = dlg.GetValue() |
363 self.pyroserver.ip_addr = dlg.GetValue() |
366 self.pyroserver.Stop() |
364 self.pyroserver.Stop() |
367 evt.Skip() |
|
368 |
365 |
369 def OnTaskBarChangePort(self, evt): |
366 def OnTaskBarChangePort(self, evt): |
370 dlg = ParamsEntryDialog(None, _("Enter a port number "), defaultValue=str(self.pyroserver.port)) |
367 dlg = ParamsEntryDialog(None, _("Enter a port number "), defaultValue=str(self.pyroserver.port)) |
371 dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port : 0 <= int(port) <= 65535 , _("Port number must be 0 <= port <= 65535!"))]) |
368 dlg.SetTests([(UnicodeType.isdigit, _("Port number must be an integer!")), (lambda port : 0 <= int(port) <= 65535 , _("Port number must be 0 <= port <= 65535!"))]) |
372 if dlg.ShowModal() == wx.ID_OK: |
369 if dlg.ShowModal() == wx.ID_OK: |
373 self.pyroserver.port = int(dlg.GetValue()) |
370 self.pyroserver.port = int(dlg.GetValue()) |
374 self.pyroserver.Stop() |
371 self.pyroserver.Stop() |
375 evt.Skip() |
|
376 |
372 |
377 def OnTaskBarChangeWorkingDir(self, evt): |
373 def OnTaskBarChangeWorkingDir(self, evt): |
378 dlg = wx.DirDialog(None, _("Choose a working directory "), self.pyroserver.workdir, wx.DD_NEW_DIR_BUTTON) |
374 dlg = wx.DirDialog(None, _("Choose a working directory "), self.pyroserver.workdir, wx.DD_NEW_DIR_BUTTON) |
379 if dlg.ShowModal() == wx.ID_OK: |
375 if dlg.ShowModal() == wx.ID_OK: |
380 self.pyroserver.workdir = dlg.GetPath() |
376 self.pyroserver.workdir = dlg.GetPath() |
381 self.pyroserver.Stop() |
377 self.pyroserver.Stop() |
382 evt.Skip() |
|
383 |
378 |
384 def OnTaskBarChangeName(self, evt): |
379 def OnTaskBarChangeName(self, evt): |
385 dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=self.pyroserver.name) |
380 dlg = ParamsEntryDialog(None, _("Enter a name "), defaultValue=self.pyroserver.name) |
386 dlg.SetTests([(lambda name : len(name) is not 0 , _("Name must not be null!"))]) |
381 dlg.SetTests([(lambda name : len(name) is not 0 , _("Name must not be null!"))]) |
387 if dlg.ShowModal() == wx.ID_OK: |
382 if dlg.ShowModal() == wx.ID_OK: |
388 self.pyroserver.name = dlg.GetValue() |
383 self.pyroserver.name = dlg.GetValue() |
389 self.pyroserver.Restart() |
384 self.pyroserver.Restart() |
390 evt.Skip() |
|
391 |
385 |
392 def _LiveShellLocals(self): |
386 def _LiveShellLocals(self): |
393 if self.pyroserver.plcobj is not None: |
387 if self.pyroserver.plcobj is not None: |
394 return {"locals":self.pyroserver.plcobj.python_threads_vars} |
388 return {"locals":self.pyroserver.plcobj.python_threads_vars} |
395 else: |
389 else: |
396 return {} |
390 return {} |
397 |
391 |
398 def OnTaskBarLiveShell(self, evt): |
392 def OnTaskBarLiveShell(self, evt): |
399 from wx import py |
393 from wx import py |
400 frame = py.crust.CrustFrame(**self._LiveShellLocals()) |
394 frame = py.crust.CrustFrame(**self._LiveShellLocals()) |
401 frame.Show() |
395 frame.Show() |
402 evt.Skip() |
|
403 |
396 |
404 def OnTaskBarWXInspector(self, evt): |
397 def OnTaskBarWXInspector(self, evt): |
405 # Activate the widget inspection tool |
398 # Activate the widget inspection tool |
406 from wx.lib.inspection import InspectionTool |
399 from wx.lib.inspection import InspectionTool |
407 if not InspectionTool().initialized: |
400 if not InspectionTool().initialized: |
408 InspectionTool().Init(**self._LiveShellLocals()) |
401 InspectionTool().Init(**self._LiveShellLocals()) |
409 |
402 |
410 wnd = wx.GetApp() |
403 wnd = wx.GetApp() |
411 InspectionTool().Show(wnd, True) |
404 InspectionTool().Show(wnd, True) |
412 |
|
413 evt.Skip() |
|
414 |
405 |
415 def OnTaskBarQuit(self, evt): |
406 def OnTaskBarQuit(self, evt): |
416 Thread(target=self.pyroserver.Quit).start() |
|
417 self.RemoveIcon() |
407 self.RemoveIcon() |
418 wx.CallAfter(wx.GetApp().Exit) |
408 wx.CallAfter(wx.GetApp().Exit) |
419 evt.Skip() |
|
420 |
409 |
421 def UpdateIcon(self, plcstatus): |
410 def UpdateIcon(self, plcstatus): |
422 if plcstatus is "Started" : |
411 if plcstatus is "Started" : |
423 currenticon = self.MakeIcon(starticon.GetImage()) |
412 currenticon = self.MakeIcon(starticon.GetImage()) |
424 elif plcstatus is "Stopped": |
413 elif plcstatus is "Stopped": |