I want to know how to use bind method with ribbon button in wxpython for python 3.4 (Phoenix version 3.0.3) because I tried all possible ways used with menus and buttons but all the time I have an error looks like:
File "C:\Anaconda3\lib\site-packages\wx\core.py", line 1200, in _EvtHandler_Bind assert source is None or hasattr(source, 'GetId') AssertionError
please help with simple example if possible. Thanks in advance.
I found a solution to my problem by using
import wx.ribbon as RB
instead of:
import wx.lib.agw.ribbon as RB
and bind with:
import wx
import wx.ribbon as RB
# Class code goes here...
self.ribbon = RB.RibbonBar(self,wx.NewId())
self.page_home = RB.RibbonPage(self.ribbon, wx.NewId(), "Home")
self.panel1 = RB.RibbonPanel(self.page_home, wx.ID_ANY, "Panel#1")
self.button_bar1 = RB.RibbonButtonBar(self.panel1)
bmp = wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_OTHER, wx.Size(32, 32))
self.button_bar1_Exit = self.button_bar1.AddButton(wx.ID_ANY, "Exit", bmp, 'Close Window')
self.button_bar1.Bind(RB.EVT_RIBBONBUTTONBAR_CLICKED, self.on_button_bar1)
def on_button_bar1(self, event):
button = event.GetButton()
if button == self.button_bar1_Exit:
self.Close()
I will leave my answer which worked for me perfectly without accepting it for a while to give a chance for better idea, if not I will accept mine.