Having a separate Menu class

Saketh Bhamidipati saketh.bhamidipati at gmail.com
Tue Jul 11 12:22:13 PDT 2006


My latest endeavor is breaking down my gigantic wx.Frame subclass into
smaller pieces. So far, I have broken all of my widgets away except for my
toolbar and menu. These last two are confusing me because they involve
binding to methods inside other widgets.

Currently, inside my wx.Frame class, I bind methods to my menu as follows:

        self.Bind(wx.EVT_MENU, self.control.OnSelectAll, editselectall)

I don't want to keep all of my menu code inside of my frame code, so I want
a few separate class (derived from wx.Menu) to represent my File, Edit,
View, etc. menus. Then there would be another class derived from
wx.MenuBarwhich should be the only object that is invoked in my frame
class.

What confuses me is binding (The problem is roughly the same for the
toolbar.). In the frame class, I just bind to constructed member variables
(like self.control in the snippet above). However, if I were to have a
separate MenuBar class with Menus inside it, I don't know how to bind these
widget methods to the menu events. I was thinking about passing a list of
functions as parameters, but I wasn't sure if this was the best way to go
about doing things, since there would be about 20 different functions to
pass.

Here's the question: How can I break my menu from the wx.Frame class and put
it into a separate file? (I'm assuming that this requires subclasses of
wx.Menu and wx.MenuBar).

-Saketh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200607=
11/24ef68ea/attachment.htm


More information about the wxpython-users mailing list