Hello all,
I have been following this list for a while, and everyone seems very helpful! I just started with wxPython, so hopefully this question will not prove too difficult--
I have a toolbar and a menubar currently in a very basic app. Right now, I want them to effectively be the same, i.e. each menu item will have a corresponding toolbar button that does the same thing. Portion of my code with the menubar and the toolbar:
# Add a tool bar:
toolbar = self.CreateToolBar()
helpbutton = toolbar.AddSimpleTool(wx.NewId(), wx.Image('resources/help-browser.png',
wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Help', 'Help for Domainspotter')
self.Bind(wx.EVT_LEFT_DOWN, self.ShowHelp, helpbutton)
exitbutton = toolbar.AddSimpleTool(wx.NewId(), wx.Image('resources/system-log-out.png',
wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Exit', 'Long help for Exit')
self.Bind(wx.EVT_LEFT_DOWN, self.OnCloseMe, exitbutton)
toolbar.Realize()
# Add a menu bar:
menubar = wx.MenuBar()
menu1 = wx.Menu()
menubar.Append(menu1, "&File")
exititem = menu1.Append(wx.NewId(), "&Exit", "Exit Domainspotter")
self.Bind(wx.EVT_MENU, self.OnCloseMe, exititem)
menu2 = wx.Menu()
menubar.Append(menu2, "&Help")
aboutitem = menu2.Append(wx.NewId(), "&About", "About Domainspotter")
self.Bind(wx.EVT_MENU, self.ShowAbout, aboutitem)
helpitem = menu2.Append(wx.NewId(), "Help", "Domainspotter Help")
self.Bind(wx.EVT_MENU, self.ShowHelp, helpitem)
self.SetMenuBar(menubar)
and then the associated functions mentioned in the Bind()'s:
def OnCloseMe(self, event):
self.Close(True)
def ShowAbout(self, event):
abouttext = wx.MessageDialog(self, self.abouttext, caption = "About Domainspotter",
style = wx.OK | wx.ICON_INFORMATION)
abouttext.ShowModal()
abouttext.Destroy()
def ShowHelp(self, event):
helptext = wx.MessageDialog(self, self.helptext, caption = "Domainspotter Help",
style = wx.OK | wx.ICON_INFORMATION)
helptext.ShowModal()
helptext.Destroy()
The menubar items work just fine. Help and about show help and about, and exit exits. But, when I press the Help or Exit buttons, which are bound to the same functions, nothing happens. No errors either.
My guess is that I have the wrong event specified in the self.Bind for the buttons. I tried wx.EVT_BUTTON as well, same deal.
Thanks in advance for the help,
Sam