]> git.saurik.com Git - wxWidgets.git/blob - wxPython/tests/test1.py
removed useless PM_USE_SESSION_APIS define (it must be defined in MacHeaders
[wxWidgets.git] / wxPython / tests / test1.py
1 #!/bin/env python
2 #----------------------------------------------------------------------------
3 # Name: test1.py
4 # Purpose: A minimal wxPython program
5 #
6 # Author: Robin Dunn
7 #
8 # Created: A long time ago, in a galaxy far, far away...
9 # RCS-ID: $Id$
10 # Copyright: (c) 1998 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------------
13
14
15 from wxPython.wx import *
16
17 #---------------------------------------------------------------------------
18
19 ## Create a new frame class, derived from the wxPython Frame.
20 class MyFrame(wxFrame):
21
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))
26
27 # Associate some events with methods of this class
28 EVT_SIZE(self, self.OnSize)
29 EVT_MOVE(self, self.OnMove)
30
31
32 # This method is called automatically when the CLOSE event is
33 # sent to this window
34 def OnCloseWindow(self, event):
35 # tell the window to kill itself
36 self.Destroy()
37
38
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
44
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
50
51
52
53 #---------------------------------------------------------------------------
54
55
56 # Every wxWindows application must have a class derived from wxApp
57 class MyApp(wxApp):
58
59 # wxWindows calls this method to initialize the application
60 def OnInit(self):
61
62 # Create an instance of our customized Frame class
63 frame = MyFrame(NULL, -1, "This is a test")
64 frame.Show(true)
65
66 # Tell wxWindows that this is our main window
67 self.SetTopWindow(frame)
68
69 # Return a success flag
70 return true
71
72 #---------------------------------------------------------------------------
73
74
75 app = MyApp(1) # Create an instance of the application class
76 app.MainLoop() # Tell it to start processing events
77
78 print 'done!'
79
80
81 #----------------------------------------------------------------------------
82
83