Python shell and wx inspector now both available even when PLC not started
authorEdouard Tisserant
Wed, 06 Mar 2013 10:30:55 +0900
changeset 959 046aeae0d71c
parent 958 511bf048b8b7
child 960 d72a866cf9b0
Python shell and wx inspector now both available even when PLC not started
Beremiz_service.py
--- a/Beremiz_service.py	Wed Mar 06 09:40:28 2013 +0900
+++ b/Beremiz_service.py	Wed Mar 06 10:30:55 2013 +0900
@@ -389,28 +389,27 @@
                     self.pyroserver.Restart()
                 evt.Skip()
             
+            def _LiveShellLocals(self):
+                if self.pyroserver.plcobj is not None:
+                    return {"locals":self.pyroserver.plcobj.python_threads_vars}
+                else:
+                    return {}
+
             def OnTaskBarLiveShell(self, evt):
-                if self.pyroserver.plcobj is not None and self.pyroserver.plcobj.python_threads_vars is not None:
-                    from wx import py
-                    #frame = py.shell.ShellFrame(locals=self.pyroserver.plcobj.python_threads_vars)
-                    frame = py.crust.CrustFrame(locals=self.pyroserver.plcobj.python_threads_vars)
-                    frame.Show()
-                else:
-                    wx.MessageBox(_("No running PLC"), _("Error"))
+                from wx import py
+                frame = py.crust.CrustFrame(**self._LiveShellLocals())
+                frame.Show()
                 evt.Skip()
             
             def OnTaskBarWXInspector(self, evt):
                 # Activate the widget inspection tool
                 from wx.lib.inspection import InspectionTool
                 if not InspectionTool().initialized:
-                    InspectionTool().Init(locals=self.pyroserver.plcobj.python_threads_vars)
-                
-                # Find a widget to be selected in the tree.  Use either the
-                # one under the cursor, if any, or this frame.
-                wnd = wx.FindWindowAtPointer()
-                if not wnd:
-                    wnd = wx.GetApp()
+                    InspectionTool().Init(**self._LiveShellLocals())
+
+                wnd = wx.GetApp()
                 InspectionTool().Show(wnd, True)
+
                 evt.Skip()
             
             def OnTaskBarQuit(self, evt):