]> git.saurik.com Git - wxWidgets.git/blame - wxPython/tests/test1.py
hopefully fixes focus assertion
[wxWidgets.git] / wxPython / tests / test1.py
CommitLineData
7bf85405
RD
1#!/bin/env python
2#----------------------------------------------------------------------------
3# Name: test1.py
4# Purpose: A minimal wxPython program
5#
6# Author: Robin Dunn
7#
af309447 8# Created: A long time ago, in a galaxy far, far away...
7bf85405
RD
9# RCS-ID: $Id$
10# Copyright: (c) 1998 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
14
b8b8dda7 15from wxPython.wx import *
7bf85405
RD
16
17#---------------------------------------------------------------------------
18
af309447 19## Create a new frame class, derived from the wxPython Frame.
7bf85405 20class MyFrame(wxFrame):
af309447 21
7bf85405 22 def __init__(self, parent, id, title):
af309447
RD
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)
7bf85405 30
af309447
RD
31
32 # This method is called automatically when the CLOSE event is
33 # sent to this window
7bf85405 34 def OnCloseWindow(self, event):
af309447 35 # tell the window to kill itself
7bf85405
RD
36 self.Destroy()
37
af309447
RD
38
39 # This method is called by the System when the window is resized,
40 # because of the association above.
7bf85405
RD
41 def OnSize(self, event):
42 size = event.GetSize()
43 print "size:", size.width, size.height
44
af309447
RD
45 # This method is called by the System when the window is moved,
46 # because of the association above.
7bf85405 47 def OnMove(self, event):
7bf85405
RD
48 pos = event.GetPosition()
49 print "pos:", pos.x, pos.y
50
51
52
53#---------------------------------------------------------------------------
54
c50f1fb9 55
af309447 56# Every wxWindows application must have a class derived from wxApp
7bf85405 57class MyApp(wxApp):
af309447
RD
58
59 # wxWindows calls this method to initialize the application
7bf85405 60 def OnInit(self):
af309447
RD
61
62 # Create an instance of our customized Frame class
7bf85405
RD
63 frame = MyFrame(NULL, -1, "This is a test")
64 frame.Show(true)
af309447
RD
65
66 # Tell wxWindows that this is our main window
7bf85405 67 self.SetTopWindow(frame)
af309447
RD
68
69 # Return a success flag
7bf85405
RD
70 return true
71
72#---------------------------------------------------------------------------
73
c50f1fb9 74
2f90df85 75app = MyApp(1) # Create an instance of the application class
af309447 76app.MainLoop() # Tell it to start processing events
7bf85405 77
cf694132 78print 'done!'
7bf85405 79
c50f1fb9 80
7bf85405 81#----------------------------------------------------------------------------
af309447 82
8bf5d46e 83