]> git.saurik.com Git - wxWidgets.git/blame - wxPython/tests/spies.py
added SetString(), deprecated SetLabel()
[wxWidgets.git] / wxPython / tests / spies.py
CommitLineData
8bf5d46e
RD
1## import all of the wxPython GUI package
2from wxPython.wx import *
3
4"""
5I am trying to write a routine which will produce an entryform which I can
6later use to write GUI entryforms for databasis work. When you run this
7program and chose option 150 (Invoer) under "L=EAers" the following error
8appears (repeated 6 times):
9
10Gtk-CRITICAL **: file gtkwidget.c: line 1592 (gtk_widget_map): assertion
11`GTK_WIDGET_VISIBLE (widget) == TRUE' failed.=20
12"""
13
14class ToetsInvoer(wxPanel):
15 def __init__(self, parent):
16 wxPanel.__init__(self, parent, -1)
17
18 wxStaticText(self, -1, "wxTextCtrl", wxPoint(5, 25), wxSize(75, 20))
19 wxTextCtrl(self, 10, "", wxPoint(80, 25), wxSize(150, 20))
20 EVT_TEXT(self, 10, self.EvtText)
21
22 wxStaticText(self, -1, "Passsword", wxPoint(5, 50), wxSize(75, 20))
23 wxTextCtrl(self, 20, "", wxPoint(80, 50), wxSize(150, 20), wxTE_PASSWORD)
24 EVT_TEXT(self, 20, self.EvtText)
25
26 wxStaticText(self, -1, "Multi-line", wxPoint(5, 75), wxSize(75, 20))
27 wxTextCtrl(self, 30, "", wxPoint(80, 75), wxSize(200, 150), wxTE_MULTILINE)
28 EVT_TEXT(self, 30, self.EvtText)
29
30 self.Show(true)
31
32 def EvtText(self, event):
33 self.log.WriteText('EvtText: %s\n' % event.GetString())
34
35#---------------------------------------------------------------------------
36
37## Create a new frame class, derived from the wxPython Frame.
38class HoofRaam(wxFrame):
39
40 def __init__(self, pa, id, titel):
41 # First, call the base class' __init__ method to create the frame
42 wxFrame.__init__(self, pa, id, titel,wxPyDefaultPosition,
43 wxSize(420, 200))
44
45 self.CreateStatusBar(2)
46 mainmenu = wxMenuBar()
47 menu = wxMenu()
48 menu.Append(100, '&Kopieer', 'Maak rugsteun')
49 menu.Append(101, '&Nuwe stel', 'Begin nuwe databasis')
50 menu.Append(150, '&Invoer', 'Toets invoervorm')
51 menu.AppendSeparator()
52 menu.Append(200, 'Kl&aar', 'Gaan uit die program uit!')
53 mainmenu.Append(menu, "&L=EAers")
54 self.SetMenuBar(mainmenu)
55# if wxPlatform == '__WXMSW__':
56# print menu.GetHelpString(100)
57# print mainmenu.GetHelpString(101)
58# print mainmenu.GetHelpString(200)
59# self.DragAcceptFiles(true)
60
61
62
63 # Associate some events with methods of this class
64 self.Connect(-1, -1, wxEVT_SIZE, self.OnSize)
65 self.Connect(-1, -1, wxEVT_MOVE, self.OnMove)
66 self.Connect(-1, -1, wxEVT_COMMAND_MENU_SELECTED, self.OnMenuCommand)
67 self.Connect(-1, -1, wxEVT_DROP_FILES, self.OnDropFiles)
68
69 self.child = None
70 #self.child = ToetsInvoer(self)
71
72 # This method is called automatically when the CLOSE event is
73 # sent to this window
74 def OnCloseWindow(self, event):
75 # tell the window to kill itself
76 self.Destroy()
77
78
79 # This method is called by the System when the window is resized,
80 # because of the association above.
81 def OnSize(self, event):
82 size = event.GetSize()
83 print "grootte:", size.width, size.height
84 event.Skip()
85
86 # This method is called by the System when the window is moved,
87 # because of the association above.
88 def OnMove(self, event):
89 pos = event.GetPosition()
90 print "pos:", pos.x, pos.y
91
92 def OnMenuCommand(self, event):
93 # why isn't this a wxMenuEvent???
94 print event, event.GetInt()
95 if event.GetInt() == 200:
96 self.Close()
97 if event.GetInt() == 150:
98 x = ToetsInvoer(self)
99 if event.GetInt() == 101:
100 print "Nommer 101 is gekies"
101
102 def OnDropFiles(self, event): #werk net in windows
103 fileList = event.GetFiles()
104 for file in fileList:
105 print file
106
107 def OnCloseWindow(self, event):
108 print 'Klaar'
109 self.Destroy()
110
111#---------------------------------------------------------------------------
112
113# Every wxWindows application must have a class derived from wxApp
114class MyProg(wxApp):
115
116 # wxWindows calls this method to initialize the application
117 def OnInit(self):
118
119 # Create an instance of our customized Frame class
120 raam = HoofRaam(NULL, -1, "Taalunie")
121 raam.Show(true)
122
123 # Tell wxWindows that this is our main window
124 self.SetTopWindow(raam)
125
126 # Return a success flag
127 return true
128
129#---------------------------------------------------------------------------
130
131
132app = MyProg(0) # Create an instance of the application class
133app.MainLoop() # Tell it to start processing events
134
135
136