]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/tests/test1.py
   2 #---------------------------------------------------------------------------- 
   4 # Purpose:      A minimal wxPython program 
   8 # Created:      A long time ago, in a galaxy far, far away... 
  10 # Copyright:    (c) 1998 by Total Control Software 
  11 # Licence:      wxWindows license 
  12 #---------------------------------------------------------------------------- 
  15 from wxPython
.wx 
import * 
  17 #--------------------------------------------------------------------------- 
  19 ## Create a new frame class, derived from the wxPython Frame. 
  20 class MyFrame(wxFrame
): 
  22     def __init__(self
, parent
, id, title
): 
  23         # First, call the base class' __init__ method to create the frame 
  24         wxFrame
.__init
__(self
, parent
, id, title
, 
  25                          wxPoint(100, 100), wxSize(160, 100)) 
  27         # Associate some events with methods of this class 
  28         EVT_SIZE(self
, self
.OnSize
) 
  29         EVT_MOVE(self
, self
.OnMove
) 
  32     # This method is called automatically when the CLOSE event is 
  34     def OnCloseWindow(self
, event
): 
  35         # tell the window to kill itself 
  39     # This method is called by the System when the window is resized, 
  40     # because of the association above. 
  41     def OnSize(self
, event
): 
  42         size 
= event
.GetSize() 
  43         print "size:", size
.width
, size
.height
 
  45     # This method is called by the System when the window is moved, 
  46     # because of the association above. 
  47     def OnMove(self
, event
): 
  48         pos 
= event
.GetPosition() 
  49         print "pos:", pos
.x
, pos
.y
 
  53 #--------------------------------------------------------------------------- 
  56 # Every wxWindows application must have a class derived from wxApp 
  59     # wxWindows calls this method to initialize the application 
  62         # Create an instance of our customized Frame class 
  63         frame 
= MyFrame(NULL
, -1, "This is a test") 
  66         # Tell wxWindows that this is our main window 
  67         self
.SetTopWindow(frame
) 
  69         # Return a success flag 
  72 #--------------------------------------------------------------------------- 
  75 app 
= MyApp(1)     # Create an instance of the application class 
  76 app
.MainLoop()     # Tell it to start processing events 
  81 #----------------------------------------------------------------------------