[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] wx Menu
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] wx Menu
- From: "Brian Fisher" <brian@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Feb 2008 23:54:02 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 24 Feb 2008 02:54:07 -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:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=UpCw05q1z9HKjxVhzVI/oQ7oGXY8j8Xy7b5ZP3dGBhI=; b=D32S7gc6yjUM0nJAee+A9ISiv8ksvoGSRw2du8KD5ru66obg3r0GQOQzrYGJxmNo3La0sLPOV6gQFyBchmnDo6LRIXsvXB5sM4wH/GoGWO+R00hG3V/iQNlkWjyEPbTfSuWYfBqE51ZOa6dFY7zgKYTlX550xxGeySLdIMlNAmw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=cQv/t9z3Rk5ZpXQeLwULhlKe7fJar35eeRkT5obYPl/f78N7wclWGNLLtHimC8l9CDxCmM1BxGG0Eo/JkkqF5CsU+QJGcBlyhQhuapvE8eONXOS4QVcKhIh/UfI7ENOFKj7npSvLHfGGCSlYsDuVkowZzMQEaj/uOaW/lLgdq1c=
- In-reply-to: <a62fab400802231531j2a03abc9g3c15c60e67ee437b@xxxxxxxxxxxxxx>
- References: <a62fab400802231531j2a03abc9g3c15c60e67ee437b@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I'm pretty sure there's no way you can use wxPython to add a menu bar
to a pygame window. You could probably figure out some platform
specific solutions for getting a menu bar (maybe using ctypes and
getting at the SDL window handle), but I don't think a cross-platform
solution exists.
On Sat, Feb 23, 2008 at 3:31 PM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
> 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
>