[wxPython-users] Is there a way to ... ?
Josiah Carlson
jcarlson at uci.edu
Wed Apr 4 19:45:57 PDT 2007
"Belinda Randolph" <belindarandolph at sbcglobal.net> wrote:
>
> My code reads a file to get the MenuSections. The file could have 4 or 5 or
> 6 menu sections. My current code assumes 5 menu sections with no error
> checking. I would much rather have a for-loop to build add the variable
> number of menus to my menubar. I'm hoping there is something like an
> "execute" statement.
>
> Thanks,
> Belinda
>
>
> menuBar.Append(menu0,'User')
> menuBar.Append(menu1,self.TL.MenuSections[0])
> menuBar.Append(menu2,self.TL.MenuSections[1])
> menuBar.Append(menu3,self.TL.MenuSections[2])
> menuBar.Append(menu4,self.TL.MenuSections[3])
> menuBar.Append(menu5,self.TL.MenuSections[4])
> self.menuBar = menuBar
> self.SetMenuBar(menuBar)
If you have the menu names in a list, can't you create a new menu for
each of the names and/or append the menus to a list?
menus = [] #might be unnecessary
for menuname in self.TL.MenuSections:
_menu = wx.Menu()
#add the submenus as necessary
#...
menus.append(_menu) #might be unnecessary
menuBar.Append(_menu, menuname)
- Josiah
More information about the wxpython-users
mailing list