--- a/Beremiz.py Thu Oct 06 22:39:05 2011 +0200
+++ b/Beremiz.py Sun Oct 09 23:30:18 2011 +0200
@@ -325,11 +325,7 @@
[ID_BEREMIZ, ID_BEREMIZMAINSPLITTER,
ID_BEREMIZPLCCONFIG, ID_BEREMIZLOGCONSOLE,
- ID_BEREMIZINSPECTOR, ID_BUILD] = [wx.NewId() for _init_ctrls in range(6)]
-
-[ID_BEREMIZRUNMENUBUILD, ID_BEREMIZRUNMENUSIMULATE,
- ID_BEREMIZRUNMENURUN, ID_BEREMIZRUNMENUSAVELOG,
-] = [wx.NewId() for _init_coll_EditMenu_Items in range(4)]
+ ID_BEREMIZINSPECTOR] = [wx.NewId() for _init_ctrls in range(5)]
class Beremiz(IDEFrame):
@@ -408,10 +404,23 @@
IDEFrame._init_ctrls(self, prnt)
self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=ID_BEREMIZINSPECTOR)
- self.Bind(wx.EVT_MENU, self.OnBuildProject, id=ID_BUILD)
- accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR),
- wx.AcceleratorEntry(wx.ACCEL_NORMAL, wx.WXK_F11, ID_BUILD)])
- self.SetAcceleratorTable(accel)
+ accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), ID_BEREMIZINSPECTOR)]
+ for method,shortcut in [("Stop", wx.WXK_F4),
+ ("Run", wx.WXK_F5),
+ ("Transfer", wx.WXK_F6),
+ ("Connect", wx.WXK_F7),
+ ("Build", wx.WXK_F11)]:
+ def OnMethodGen(obj,meth):
+ def OnMethod(evt):
+ if obj.PluginRoot is not None:
+ obj.PluginRoot.CallMethod('_'+meth)
+ wx.CallAfter(self.RefreshAll)
+ return OnMethod
+ newid = wx.NewId()
+ self.Bind(wx.EVT_MENU, OnMethodGen(self,method), id=newid)
+ accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut,newid)]
+
+ self.SetAcceleratorTable(wx.AcceleratorTable(accels))
self.PLCConfig = wx.ScrolledWindow(id=ID_BEREMIZPLCCONFIG,
name='PLCConfig', parent=self.LeftNoteBook, pos=wx.Point(0, 0),
@@ -525,10 +534,6 @@
wnd = self
InspectionTool().Show(wnd, True)
- def OnBuildProject(self, evt):
- if self.PluginRoot is not None:
- self.PluginRoot._build()
-
def OnLogConsoleDClick(self, event):
wx.CallAfter(self.SearchLineForError)
event.Skip()
--- a/plugger.py Thu Oct 06 22:39:05 2011 +0200
+++ b/plugger.py Sun Oct 09 23:30:18 2011 +0200
@@ -651,6 +651,11 @@
return True
return False
+ def CallMethod(self, method):
+ for d in self.PluginMethods:
+ if d["method"]==method and d.get("enabled", True) and d.get("shown", True):
+ getattr(self, method)()
+
def _GetClassFunction(name):
def GetRootClass():
return getattr(__import__("plugins." + name), name).RootClass
@@ -1385,7 +1390,7 @@
return plc_main_code
- def _build(self):
+ def _Build(self):
"""
Method called by user to (re)build SoftPLC and plugin tree
"""
@@ -1946,7 +1951,7 @@
{"bitmap" : opjimg("Build"),
"name" : _("Build"),
"tooltip" : _("Build project into build folder"),
- "method" : "_build"},
+ "method" : "_Build"},
{"bitmap" : opjimg("Clean"),
"name" : _("Clean"),
"enabled" : False,