# HG changeset patch # User laurent # Date 1339370658 -7200 # Node ID 36e823a90d94d4270cc15ddd75b0378b9a2343a9 # Parent 42c0062655a77eb7c2d605c13ae966e2d4ef4a88 Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON) diff -r 42c0062655a7 -r 36e823a90d94 ConfTreeNodeEditor.py --- a/ConfTreeNodeEditor.py Mon Jun 11 01:22:20 2012 +0200 +++ b/ConfTreeNodeEditor.py Mon Jun 11 01:24:18 2012 +0200 @@ -306,12 +306,18 @@ if "method" in confnode_method and confnode_method.get("shown",True): id = wx.NewId() label = confnode_method["name"] + bitmap_path = confnode_method.get("bitmap", "Unknown") + if os.path.splitext(bitmap_path)[1] == "": + bitmap_path = Bpath("images", "%s.png" % bitmap_path) button = GenBitmapTextButton(id=id, parent=self.ParamsEditor, - bitmap=wx.Bitmap(Bpath("images", "%s.png"%confnode_method.get("bitmap", "Unknown"))), label=label, + bitmap=wx.Bitmap(bitmap_path), label=label, name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER) button.SetFont(normal_bt_font) button.SetToolTipString(confnode_method["tooltip"]) - button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), id=id) + if confnode_method.get("push", False): + button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True)) + else: + button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), id=id) # a fancy underline on mouseover def setFontStyle(b, s): def fn(event): @@ -483,7 +489,7 @@ wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU) return res - def GetButtonCallBackFunction(self, method): + def GetButtonCallBackFunction(self, method, push=False): """ Generate the callbackfunc for a given confnode method""" def OnButtonClick(event): # Disable button to prevent re-entrant call @@ -493,7 +499,8 @@ # Re-enable button event.GetEventObject().Enable() - event.Skip() + if not push: + event.Skip() return OnButtonClick def GetChoiceCallBackFunction(self, choicectrl, path):