[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] wxPython and pygame - pygame window will not disappear



I've attached my template for a new app. Its short. It
has a Frame, File->Exit menu and an empty panel. I
adapted it from a tutorial so it has comments on whats
what.

Mark

--- Ian Mallett <geometrian@xxxxxxxxx> wrote:

> I'm afraid I don't know the answer to your question,
> Mark.
> 
> However, if there are any experts out there, I would
> like a simple way to
> make a menu in wxPython.  The demos are
> unnecessarily complicated, and I
> have no idea where to start.  For instance, a simple
> Dialog box takes 5
> lines including the import statement, but their
> example is 3 pages long?!
> 
> Ian
> 



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
#----------------------------------------------------------------------------
# Name:         
# Purpose:      
#
# Author:       
#
# TODO:  
#
#----------------------------------------------------------------------------

import wx

class MainFrame(wx.Frame):
    """
    This is the MainFrame.
    """
    def __init__(self, title):                
        wx.Frame.__init__(self, None, -1, title,
                          pos=(150, 150), size=(640, 480))


        # Create the menubar
        menuBar = wx.MenuBar()

        # and a menu 
        menu = wx.Menu()

        # add an item to the menu, using \tKeyName automatically
        # creates an accelerator, the third param is some help text
        # that will show up in the statusbar
        menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit this simple sample")

        # and put the menu on the menubar
        menuBar.Append(menu, "&File")
        self.SetMenuBar(menuBar)

        self.Bind(wx.EVT_MENU, self.CloseWindow, id=wx.ID_EXIT)        

        # A sizer so we can add stuff to the frame.
        sizer = wx.BoxSizer(wx.VERTICAL)

        # A panel (empty)!
        pnl = wx.Panel(self)

        sizer.Add(pnl, 1, wx.EXPAND)        
        self.SetSizer(sizer)
        self.SetAutoLayout(True)

    def CloseWindow(self, event):
        self.Close()
               

class MyApp(wx.App):
    def OnInit(self):

        frame = MainFrame("Yay")
        self.SetTopWindow(frame)
        frame.Show(True)
        return True


if __name__ == '__main__':
    app = MyApp(0)
    app.MainLoop()