]>
git.saurik.com Git - wxWidgets.git/blob - utils/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 ## import all of the wxPython GUI package
16 from wxPython
.wx
import *
19 #---------------------------------------------------------------------------
21 ## Create a new frame class, derived from the wxPython Frame.
22 class MyFrame(wxFrame
):
24 def __init__(self
, parent
, id, title
):
25 # First, call the base class' __init__ method to create the frame
26 wxFrame
.__init
__(self
, parent
, id, title
,
27 wxPoint(100, 100), wxSize(160, 100))
29 # Associate some events with methods of this class
30 EVT_SIZE(self
, self
.OnSize
)
31 EVT_MOVE(self
, self
.OnMove
)
34 # This method is called automatically when the CLOSE event is
36 def OnCloseWindow(self
, event
):
37 # tell the window to kill itself
41 # This method is called by the System when the window is resized,
42 # because of the association above.
43 def OnSize(self
, event
):
44 size
= event
.GetSize()
45 print "size:", size
.width
, size
.height
47 # This method is called by the System when the window is moved,
48 # because of the association above.
49 def OnMove(self
, event
):
50 pos
= event
.GetPosition()
51 print "pos:", pos
.x
, pos
.y
55 #---------------------------------------------------------------------------
57 # Every wxWindows application must have a class derived from wxApp
60 # wxWindows calls this method to initialize the application
63 # Create an instance of our customized Frame class
64 frame
= MyFrame(NULL
, -1, "This is a test")
67 # Tell wxWindows that this is our main window
68 self
.SetTopWindow(frame
)
70 # Return a success flag
73 #---------------------------------------------------------------------------
76 app
= MyApp(0) # Create an instance of the application class
77 app
.MainLoop() # Tell it to start processing events
81 #----------------------------------------------------------------------------