387 if dlg.ShowModal() == wx.ID_OK: |
387 if dlg.ShowModal() == wx.ID_OK: |
388 self.pyroserver.name = dlg.GetValue() |
388 self.pyroserver.name = dlg.GetValue() |
389 self.pyroserver.Restart() |
389 self.pyroserver.Restart() |
390 evt.Skip() |
390 evt.Skip() |
391 |
391 |
|
392 def _LiveShellLocals(self): |
|
393 if self.pyroserver.plcobj is not None: |
|
394 return {"locals":self.pyroserver.plcobj.python_threads_vars} |
|
395 else: |
|
396 return {} |
|
397 |
392 def OnTaskBarLiveShell(self, evt): |
398 def OnTaskBarLiveShell(self, evt): |
393 if self.pyroserver.plcobj is not None and self.pyroserver.plcobj.python_threads_vars is not None: |
399 from wx import py |
394 from wx import py |
400 frame = py.crust.CrustFrame(**self._LiveShellLocals()) |
395 #frame = py.shell.ShellFrame(locals=self.pyroserver.plcobj.python_threads_vars) |
401 frame.Show() |
396 frame = py.crust.CrustFrame(locals=self.pyroserver.plcobj.python_threads_vars) |
|
397 frame.Show() |
|
398 else: |
|
399 wx.MessageBox(_("No running PLC"), _("Error")) |
|
400 evt.Skip() |
402 evt.Skip() |
401 |
403 |
402 def OnTaskBarWXInspector(self, evt): |
404 def OnTaskBarWXInspector(self, evt): |
403 # Activate the widget inspection tool |
405 # Activate the widget inspection tool |
404 from wx.lib.inspection import InspectionTool |
406 from wx.lib.inspection import InspectionTool |
405 if not InspectionTool().initialized: |
407 if not InspectionTool().initialized: |
406 InspectionTool().Init(locals=self.pyroserver.plcobj.python_threads_vars) |
408 InspectionTool().Init(**self._LiveShellLocals()) |
407 |
409 |
408 # Find a widget to be selected in the tree. Use either the |
410 wnd = wx.GetApp() |
409 # one under the cursor, if any, or this frame. |
|
410 wnd = wx.FindWindowAtPointer() |
|
411 if not wnd: |
|
412 wnd = wx.GetApp() |
|
413 InspectionTool().Show(wnd, True) |
411 InspectionTool().Show(wnd, True) |
|
412 |
414 evt.Skip() |
413 evt.Skip() |
415 |
414 |
416 def OnTaskBarQuit(self, evt): |
415 def OnTaskBarQuit(self, evt): |
417 Thread(target=self.pyroserver.Quit).start() |
416 Thread(target=self.pyroserver.Quit).start() |
418 self.RemoveIcon() |
417 self.RemoveIcon() |