]>
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 #----------------------------------------------------------------------------
17 #from wxPython import *
21 ## import all of the wxPython GUI package
23 from wxPython
.wx
import *
26 #---------------------------------------------------------------------------
28 ## Create a new frame class, derived from the wxPython Frame.
29 class MyFrame(wxFrame
):
31 def __init__(self
, parent
, id, title
):
32 # First, call the base class' __init__ method to create the frame
33 wxFrame
.__init
__(self
, parent
, id, title
,
34 wxPoint(100, 100), wxSize(160, 100))
36 # Associate some events with methods of this class
37 EVT_SIZE(self
, self
.OnSize
)
38 EVT_MOVE(self
, self
.OnMove
)
41 # This method is called automatically when the CLOSE event is
43 def OnCloseWindow(self
, event
):
44 # tell the window to kill itself
48 # This method is called by the System when the window is resized,
49 # because of the association above.
50 def OnSize(self
, event
):
51 size
= event
.GetSize()
52 print "size:", size
.width
, size
.height
54 # This method is called by the System when the window is moved,
55 # because of the association above.
56 def OnMove(self
, event
):
57 pos
= event
.GetPosition()
58 print "pos:", pos
.x
, pos
.y
62 #---------------------------------------------------------------------------
67 # Every wxWindows application must have a class derived from wxApp
71 # wxWindows calls this method to initialize the application
74 # Create an instance of our customized Frame class
75 frame
= MyFrame(NULL
, -1, "This is a test")
78 # Tell wxWindows that this is our main window
79 self
.SetTopWindow(frame
)
81 # Return a success flag
84 #---------------------------------------------------------------------------
100 if __name__
== '__main__':
103 app
= MyApp(0) # Create an instance of the application class
104 app
.MainLoop() # Tell it to start processing events
110 #----------------------------------------------------------------------------
113 # Revision 1.6 1999/06/28 21:39:48 VZ
114 # 1. wxStaticLine implemented (generic (ugly) and MSW versions)
115 # 2. wxTextDialog looks fine under MSW again
116 # 3. startup tips added: code, sample, docs
117 # 4. read-only text controls don't participate in TAB traversal
119 # Revision 1.3 1998/12/15 20:44:34 RD
120 # Changed the import semantics from "from wxPython import *" to "from
121 # wxPython.wx import *" This is for people who are worried about
122 # namespace pollution, they can use "from wxPython import wx" and then
123 # prefix all the wxPython identifiers with "wx."
125 # Added wxTaskbarIcon for wxMSW.
127 # Made the events work for wxGrid.
131 # Added wxMiniFrame for wxGTK, (untested.)
133 # Changed many of the args and return values that were pointers to gdi
134 # objects to references to reflect changes in the wxWindows API.
137 # Other assorted fixes and additions.
139 # Revision 1.2 1998/10/02 06:42:27 RD
141 # Version 0.4 of wxPython for MSW.
143 # Revision 1.1 1998/08/09 08:28:05 RD