]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/DialogUnits.py
reSWIGged
[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
RD
13# Updated 11/9/2003 by Jeff Grimmett (grimmtooth@softhome.net)
14#
15# o Converted for V2.5 compatability
16#
cf694132 17
8fa876ca 18import wx
cf694132
RD
19
20#---------------------------------------------------------------------------
21
8fa876ca
RD
22# Create a new frame class, derived from the wxPython Frame.
23class MyFrame(wx.Frame):
cf694132
RD
24
25 def __init__(self, parent, id, title):
26 # First, call the base class' __init__ method to create the frame
8fa876ca 27 wx.Frame.__init__(self, parent, id, title, (100, 100), (160, 100))
cf694132
RD
28
29 # Associate some events with methods of this class
8fa876ca
RD
30 self.Bind(wx.EVT_SIZE, self.OnSize)
31 self.Bind(wx.EVT_MOVE, self.OnMove)
32 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
cf694132
RD
33
34 # Add a panel and some controls to display the size and position
8fa876ca 35 panel = wx.Panel(self, -1)
cf694132 36
8fa876ca
RD
37 wx.StaticText(panel, -1, "Size:",
38 wx.DLG_PNT(panel, (4, 4)), wx.DefaultSize
39 )
cf694132 40
8fa876ca
RD
41 wx.StaticText(panel, -1, "Pos:",
42 wx.DLG_PNT(panel, (4, 16)), wx.DefaultSize
43 )
8bf5d46e 44
8fa876ca
RD
45 self.sizeCtrl = wx.TextCtrl(panel, -1, "",
46 wx.DLG_PNT(panel, (24, 4)),
47 wx.DLG_SZE(panel, (36, -1)),
48 wx.TE_READONLY)
49
50 self.posCtrl = wx.TextCtrl(panel, -1, "",
51 wx.DLG_PNT(panel, (24, 16)),
52 wx.DLG_SZE(panel, (36, -1)),
53 wx.TE_READONLY)
54
55 #print wx.DLG_PNT(panel, (24, 4)), wx.DLG_SZE(panel, (36, -1))
56 #print wx.DLG_PNT(panel, (24, 16)),wx.DLG_SZE(panel, (36, -1))
cf694132
RD
57
58 # This method is called automatically when the CLOSE event is
59 # sent to this window
60 def OnCloseWindow(self, event):
61 # tell the window to kill itself
62 self.Destroy()
63
cf694132
RD
64 # This method is called by the System when the window is resized,
65 # because of the association above.
66 def OnSize(self, event):
67 size = event.GetSize()
68 self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
69
70 # tell the event system to continue looking for an event handler,
71 # so the default handler will get called.
72 event.Skip()
73
74 # This method is called by the System when the window is moved,
75 # because of the association above.
76 def OnMove(self, event):
77 pos = event.GetPosition()
78 self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
79
80
81
82#---------------------------------------------------------------------------
83# if running standalone
84
85if __name__ == "__main__":
86 # Every wxWindows application must have a class derived from wxApp
8fa876ca 87 class MyApp(wx.App):
cf694132
RD
88
89 # wxWindows calls this method to initialize the application
90 def OnInit(self):
91
92 # Create an instance of our customized Frame class
493f1553 93 frame = MyFrame(None, -1, "This is a test")
1e4a197e 94 frame.Show(True)
cf694132
RD
95
96 # Tell wxWindows that this is our main window
97 self.SetTopWindow(frame)
98
99 # Return a success flag
1e4a197e 100 return True
cf694132
RD
101
102
103 app = MyApp(0) # Create an instance of the application class
104 app.MainLoop() # Tell it to start processing events
105
106
107#---------------------------------------------------------------------------
108# if running as part of the Demo Framework...
109
110def runTest(frame, nb, log):
111 win = MyFrame(frame, -1, "This is a test")
112 frame.otherWin = win
1e4a197e 113 win.Show(True)
cf694132
RD
114
115
116overview = """\
117A simple example that shows how to use Dialog Units.
118"""
119
120#----------------------------------------------------------------------------
121#
122
123
124
125
126
127
128
129
130