]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/DialogUnits.py
nicer version compilation fix for wxUSE_WCHAR_T=0 (why should we duplicate definition...
[wxWidgets.git] / wxPython / demo / DialogUnits.py
... / ...
CommitLineData
1#!/usr/bin/env python
2#----------------------------------------------------------------------------
3# Name: DialogUnits.py
4# Purpose: A minimal wxPython program that is a bit smarter than test1.
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## import all of the wxPython GUI package
16from wxPython.wx import *
17
18
19#---------------------------------------------------------------------------
20
21## Create a new frame class, derived from the wxPython Frame.
22class MyFrame(wxFrame):
23
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))
28
29 # Associate some events with methods of this class
30 EVT_SIZE(self, self.OnSize)
31 EVT_MOVE(self, self.OnMove)
32 EVT_CLOSE(self, self.OnCloseWindow)
33
34 # Add a panel and some controls to display the size and position
35 panel = wxPanel(self, -1)
36 wxStaticText(panel, -1, "Size:",
37 wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
38 wxStaticText(panel, -1, "Pos:",
39 wxDLG_PNT(panel, wxPoint(4, 16)), wxDefaultSize)
40 self.sizeCtrl = wxTextCtrl(panel, -1, "",
41 wxDLG_PNT(panel, wxPoint(24, 4)),
42 wxDLG_SZE(panel, wxSize(36, -1)),
43 wxTE_READONLY)
44
45 self.posCtrl = wxTextCtrl(panel, -1, "",
46 wxDLG_PNT(panel, wxPoint(24, 16)),
47 wxDLG_SZE(panel, wxSize(36, -1)),
48 wxTE_READONLY)
49
50 #print wxDLG_PNT(panel, wxPoint(24, 4)), wxDLG_SZE(panel, wxSize(36, -1))
51 #print wxDLG_PNT(panel, wxPoint(24, 16)),wxDLG_SZE(panel, wxSize(36, -1))
52
53
54 # This method is called automatically when the CLOSE event is
55 # sent to this window
56 def OnCloseWindow(self, event):
57 # tell the window to kill itself
58 self.Destroy()
59
60
61 # This method is called by the System when the window is resized,
62 # because of the association above.
63 def OnSize(self, event):
64 size = event.GetSize()
65 self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
66
67 # tell the event system to continue looking for an event handler,
68 # so the default handler will get called.
69 event.Skip()
70
71 # This method is called by the System when the window is moved,
72 # because of the association above.
73 def OnMove(self, event):
74 pos = event.GetPosition()
75 self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
76
77
78
79#---------------------------------------------------------------------------
80# if running standalone
81
82if __name__ == "__main__":
83 # Every wxWindows application must have a class derived from wxApp
84 class MyApp(wxApp):
85
86 # wxWindows calls this method to initialize the application
87 def OnInit(self):
88
89 # Create an instance of our customized Frame class
90 frame = MyFrame(None, -1, "This is a test")
91 frame.Show(true)
92
93 # Tell wxWindows that this is our main window
94 self.SetTopWindow(frame)
95
96 # Return a success flag
97 return true
98
99
100 app = MyApp(0) # Create an instance of the application class
101 app.MainLoop() # Tell it to start processing events
102
103
104#---------------------------------------------------------------------------
105# if running as part of the Demo Framework...
106
107def runTest(frame, nb, log):
108 win = MyFrame(frame, -1, "This is a test")
109 frame.otherWin = win
110 win.Show(true)
111
112
113overview = """\
114A simple example that shows how to use Dialog Units.
115"""
116
117#----------------------------------------------------------------------------
118#
119
120
121
122
123
124
125
126
127