diff -r 2f61931520c9 -r 2a0e04091898 demo_menu.py --- a/demo_menu.py Fri Jan 18 22:36:50 2013 +0100 +++ b/demo_menu.py Sat Jan 19 13:05:21 2013 +0100 @@ -4,28 +4,22 @@ import locale locale.setlocale(locale.LC_ALL, '') -from tuikit import Application, MenuBar, Menu, Window, VerticalLayout +from tuikit import Application, MenuBar, MenuButton, Menu, Window class MyApplication(Application): def __init__(self): Application.__init__(self) - self.top.add_handler('keypress', self.on_top_keypress) - - menubar = MenuBar() - self.top.add(menubar) + self.top.add_handler('keypress', self.on_top_keypress, last=True) helpwin = Window() + helpwin.title = 'About' + helpwin.hide() self.top.add(helpwin) - helpwin.x = 10 - helpwin.y = 5 - helpwin.allow_layout = False - helpwin.hidden = True - helpwin.title = 'About' + helpwin.move(10, 5) #helpwin.closebutton = False #helpwin.resizable = False - filemenu = Menu([ ('New', None), None, @@ -34,21 +28,21 @@ None, ('Quit', self.terminate), ]) - self.top.add(filemenu) - editmenu = Menu([('Copy', None), ('Paste', None)]) helpmenu = Menu([('About', helpwin)]) - self.top.add(editmenu) - self.top.add(helpmenu) - - menubar.setitems([ + menubar_items = [ ('File', filemenu), ('Edit', editmenu), ('Help', helpmenu), - ]) + ] - self.top.layout = VerticalLayout() + menubar = MenuBar(menubar_items) + self.top.add(menubar, halign='fill') + + menu = Menu([('Copy', None), ('Paste', None)]) + menubtn = MenuButton('MenuButton', menu) + self.top.add(menubtn, halign='center', valign='center') def on_top_keypress(self, ev): if ev.keyname == 'escape':