[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] wx Menu
- To: "pygame-users@xxxxxxxx" <pygame-users@xxxxxxxx>
- Subject: [pygame] wx Menu
- From: "Ian Mallett" <geometrian@xxxxxxxxx>
- Date: Sat, 23 Feb 2008 15:31:23 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 23 Feb 2008 18:31:30 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=gamma;        h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type;        bh=IjrIU9foD+jxWH4orNt6RIheAFcmuwi1vU0BMQq7fak=;        b=A1iuCgaaTxztlAr6mkIeu3PN6rD3qMoF2zDlZDIDhoUh3Aw8WYhAIPBSkApOuDQTFlVUwzKbYCtyauiVJ/VaUH+zEDI7Mjb173bN4vCRvXLQmTO3efpu7P2VBvawKUIIGQolTh2eD0GxtJJJBHbmZpPXeGJ08H1u/1Zhnp7I34U=
- Domainkey-signature: a=rsa-sha1; c=nofws;        d=gmail.com; s=gamma;        h=message-id:date:from:to:subject:mime-version:content-type;        b=gyDXOuZGHI0dPYtWNhy2UbIKks+DbGyDJ8PAFpe09zhDpxa5Yqy97Tyyb8qD5bKABDkWerSVu4fMIzPgiHSOrHZY3HzBKNYlkG3RG4HO1bqprjFzjBuYmAn7kIByqiZ2r3H/6Oz6EAsPe5X9snQqwoJhazHnL5W9yKABAg0bNnw=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I got the following code:
import wx
class SimpleDemo(wx.Frame):
    def __init__(self, parent):
        # Any variable with the equals after it is optional
        wx.Frame.__init__(self, parent, -1, "Window title", size=(300, 200), pos = (50, 50))
        # Define the panel so we can place things on it
        #panel = wx.Panel(self, -1)
        ###########
        # MENU BAR
        ###########
        # First define the menubar object
        menubar = wx.MenuBar()
        # Now define our pulldown menus.
        file_menu = wx.Menu()
        about = wx.MenuItem(file_menu, 2, '&About') # note the id's (2 in this case) must match in the binding below
 
      self.Bind(wx.EVT_MENU, self.OnDummy, id=2)   # This is the
binding, which tells Python what to do when someone clicks that entry.
The function name (OnDummy in this case) can be anything, but the
function must exist. 
        file_menu.AppendItem(about) # add it to the file menu
        file_menu.AppendSeparator() # a separator, strictly cosmetic
        quit_item = wx.MenuItem(file_menu, 3, 'Quit!')
 
      self.Bind(wx.EVT_MENU, self.OnDummy, id=3) # again, binding an
action. Note that the function name (OnQuit) can be anything, but must
exist.
        file_menu.AppendItem(quit_item)
        # Another pulldown menu         
        help_menu = wx.Menu()
        help_item = wx.MenuItem(help_menu, 4, 'Help')
        self.Bind(wx.EVT_MENU, self.OnDummy, id=4)
        help_menu.AppendItem(help_item) 
        menubar.Append(file_menu, '&File   ')
        menubar.Append(help_menu, 'Help   ')
        
        self.SetMenuBar(menubar)
        self.Show()
    def OnDummy(self, event):
        print "Clicked!"
It works; drawing a menubar.  Is there a way to do it in a pygame window?
Thanks,
Ian