358 |
358 |
359 inspectorID = wx.NewId() |
359 inspectorID = wx.NewId() |
360 self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID) |
360 self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID) |
361 accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL | wx.ACCEL_ALT, ord('I'), inspectorID)] |
361 accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL | wx.ACCEL_ALT, ord('I'), inspectorID)] |
362 |
362 |
|
363 self.methodLock = Lock() |
|
364 |
363 for method, shortcut in [("Stop", wx.WXK_F4), |
365 for method, shortcut in [("Stop", wx.WXK_F4), |
364 ("Run", wx.WXK_F5), |
366 ("Run", wx.WXK_F5), |
365 ("Transfer", wx.WXK_F6), |
367 ("Transfer", wx.WXK_F6), |
366 ("Connect", wx.WXK_F7), |
368 ("Connect", wx.WXK_F7), |
367 ("Clean", wx.WXK_F9), |
369 ("Clean", wx.WXK_F9), |
368 ("Build", wx.WXK_F11)]: |
370 ("Build", wx.WXK_F11)]: |
369 def OnMethodGen(obj, meth): |
371 def OnMethodGen(obj, meth): |
370 def OnMethod(evt): |
372 def OnMethod(evt): |
371 if obj.CTR is not None: |
373 if obj.CTR is not None: |
372 obj.CTR.CallMethod('_'+meth) |
374 if obj.methodLock.acquire(False): |
373 wx.CallAfter(self.RefreshStatusToolBar) |
375 obj.CTR.CallMethod('_'+meth) |
|
376 obj.methodLock.release() |
|
377 wx.CallAfter(obj.RefreshStatusToolBar) |
|
378 else: |
|
379 # Postpone call if one of method already running |
|
380 # can happen because of long method using log, |
|
381 # itself calling wx.Yield |
|
382 wx.CallLater(50, OnMethod, evt) |
374 return OnMethod |
383 return OnMethod |
375 newid = wx.NewId() |
384 newid = wx.NewId() |
376 self.Bind(wx.EVT_MENU, OnMethodGen(self, method), id=newid) |
385 self.Bind(wx.EVT_MENU, OnMethodGen(self, method), id=newid) |
377 accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut, newid)] |
386 accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, shortcut, newid)] |
378 |
387 |