ConfTreeNodeEditor.py
changeset 767 36e823a90d94
parent 762 aaacc83aa86b
child 775 172be32a2482
equal deleted inserted replaced
766:42c0062655a7 767:36e823a90d94
   304         
   304         
   305         for confnode_method in self.Controler.ConfNodeMethods:
   305         for confnode_method in self.Controler.ConfNodeMethods:
   306             if "method" in confnode_method and confnode_method.get("shown",True):
   306             if "method" in confnode_method and confnode_method.get("shown",True):
   307                 id = wx.NewId()
   307                 id = wx.NewId()
   308                 label = confnode_method["name"]
   308                 label = confnode_method["name"]
       
   309                 bitmap_path = confnode_method.get("bitmap", "Unknown")
       
   310                 if os.path.splitext(bitmap_path)[1] == "":
       
   311                     bitmap_path = Bpath("images", "%s.png" % bitmap_path)
   309                 button = GenBitmapTextButton(id=id, parent=self.ParamsEditor,
   312                 button = GenBitmapTextButton(id=id, parent=self.ParamsEditor,
   310                     bitmap=wx.Bitmap(Bpath("images", "%s.png"%confnode_method.get("bitmap", "Unknown"))), label=label, 
   313                     bitmap=wx.Bitmap(bitmap_path), label=label, 
   311                     name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER)
   314                     name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER)
   312                 button.SetFont(normal_bt_font)
   315                 button.SetFont(normal_bt_font)
   313                 button.SetToolTipString(confnode_method["tooltip"])
   316                 button.SetToolTipString(confnode_method["tooltip"])
   314                 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), id=id)
   317                 if confnode_method.get("push", False):
       
   318                     button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True))
       
   319                 else:
       
   320                     button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), id=id)
   315                 # a fancy underline on mouseover
   321                 # a fancy underline on mouseover
   316                 def setFontStyle(b, s):
   322                 def setFontStyle(b, s):
   317                     def fn(event):
   323                     def fn(event):
   318                         b.SetFont(s)
   324                         b.SetFont(s)
   319                         b.Refresh()
   325                         b.Refresh()
   481         if StructChanged:
   487         if StructChanged:
   482             wx.CallAfter(self.RefreshConfNodeParamsSizer)
   488             wx.CallAfter(self.RefreshConfNodeParamsSizer)
   483         wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU)
   489         wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU)
   484         return res
   490         return res
   485     
   491     
   486     def GetButtonCallBackFunction(self, method):
   492     def GetButtonCallBackFunction(self, method, push=False):
   487         """ Generate the callbackfunc for a given confnode method"""
   493         """ Generate the callbackfunc for a given confnode method"""
   488         def OnButtonClick(event):
   494         def OnButtonClick(event):
   489             # Disable button to prevent re-entrant call 
   495             # Disable button to prevent re-entrant call 
   490             event.GetEventObject().Disable()
   496             event.GetEventObject().Disable()
   491             # Call
   497             # Call
   492             getattr(self.Controler,method)()
   498             getattr(self.Controler,method)()
   493             # Re-enable button 
   499             # Re-enable button 
   494             event.GetEventObject().Enable()
   500             event.GetEventObject().Enable()
   495             
   501             
   496             event.Skip()
   502             if not push:
       
   503                 event.Skip()
   497         return OnButtonClick
   504         return OnButtonClick
   498     
   505     
   499     def GetChoiceCallBackFunction(self, choicectrl, path):
   506     def GetChoiceCallBackFunction(self, choicectrl, path):
   500         def OnChoiceChanged(event):
   507         def OnChoiceChanged(event):
   501             res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())
   508             res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())