]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/DialogUnits.py
Docstring fixes
[wxWidgets.git] / wxPython / demo / DialogUnits.py
CommitLineData
8bf5d46e 1#!/usr/bin/env python
cf694132
RD
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#----------------------------------------------------------------------------
8fa876ca 13#
cf694132 14
8fa876ca 15import wx
cf694132
RD
16
17#---------------------------------------------------------------------------
18
8fa876ca
RD
19# Create a new frame class, derived from the wxPython Frame.
20class MyFrame(wx.Frame):
cf694132
RD
21
22 def __init__(self, parent, id, title):
23 # First, call the base class' __init__ method to create the frame
8fa876ca 24 wx.Frame.__init__(self, parent, id, title, (100, 100), (160, 100))
cf694132
RD
25
26 # Associate some events with methods of this class
8fa876ca
RD
27 self.Bind(wx.EVT_SIZE, self.OnSize)
28 self.Bind(wx.EVT_MOVE, self.OnMove)
29 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
cf694132
RD
30
31 # Add a panel and some controls to display the size and position
8fa876ca 32 panel = wx.Panel(self, -1)
cf694132 33
8fa876ca
RD
34 wx.StaticText(panel, -1, "Size:",
35 wx.DLG_PNT(panel, (4, 4)), wx.DefaultSize
36 )
cf694132 37
8fa876ca
RD
38 wx.StaticText(panel, -1, "Pos:",
39 wx.DLG_PNT(panel, (4, 16)), wx.DefaultSize
40 )
8bf5d46e 41
8fa876ca
RD
42 self.sizeCtrl = wx.TextCtrl(panel, -1, "",
43 wx.DLG_PNT(panel, (24, 4)),
44 wx.DLG_SZE(panel, (36, -1)),
45 wx.TE_READONLY)
46
47 self.posCtrl = wx.TextCtrl(panel, -1, "",
48 wx.DLG_PNT(panel, (24, 16)),
49 wx.DLG_SZE(panel, (36, -1)),
50 wx.TE_READONLY)
51
52 #print wx.DLG_PNT(panel, (24, 4)), wx.DLG_SZE(panel, (36, -1))
53 #print wx.DLG_PNT(panel, (24, 16)),wx.DLG_SZE(panel, (36, -1))
cf694132
RD
54
55 # This method is called automatically when the CLOSE event is
56 # sent to this window
57 def OnCloseWindow(self, event):
58 # tell the window to kill itself
59 self.Destroy()
60
cf694132
RD
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
8fa876ca 84 class MyApp(wx.App):
cf694132
RD
85
86 # wxWindows calls this method to initialize the application
87 def OnInit(self):
88
89 # Create an instance of our customized Frame class
493f1553 90 frame = MyFrame(None, -1, "This is a test")
1e4a197e 91 frame.Show(True)
cf694132
RD
92
93 # Tell wxWindows that this is our main window
94 self.SetTopWindow(frame)
95
96 # Return a success flag
1e4a197e 97 return True
cf694132
RD
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
1e4a197e 110 win.Show(True)
cf694132
RD
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