This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwxText.py~
138 lines (108 loc) · 4.51 KB
/
wxText.py~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/python
"""
Hello World, but with more meat.
"""
import wx
import wx.lib.buttons as buttons # want to create a button that does something
class HelloFrame(wx.Frame):
"""
A Frame that says Hello World
"""
def __init__(self, *args, **kw):
# ensure the parent's __init__ is called
super(HelloFrame, self).__init__(*args, **kw)
# create a panel in the frame
pnl = wx.Panel(self)
# and put some text with a larger bold font on it
st = wx.StaticText(pnl, label="Hello World!", pos=(25,25))
font = st.GetFont()
font.PointSize += 10
font = font.Bold()
st.SetFont(font)
# create a menu bar
self.makeMenuBar()
# and a status bar
self.CreateStatusBar()
self.SetStatusText("Welcome to wxPython!")
#my buttons
btn1 = buttons.GenButton(pnl,-1,"Press Me",pos=(100,75))
# What other things can I put on the panel
# Would like to get a txt box and be able to read txt in?
# How do I do that.
'''
it seemed to change the single quotes to 3 double quotes
'''
def makeMenuBar(self):
"""
A menu bar is composed of menus, which are composed of menu items.
This method builds a set of menus and binds handlers to be called
when the menu item is selected.
"""
# Make a file menu with Hello and Exit items
fileMenu = wx.Menu()
# The "\t..." syntax defines an accelerator key that also triggers
# the same event
helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",
"Help string shown in status bar for this menu item")
fileMenu.AppendSeparator()
# When using a stock ID we don't need to specify the menu item's
# label
exitItem = fileMenu.Append(wx.ID_EXIT)
# the wtf menu
wtfMenu = wx.Menu()
whatItem = wtfMenu.Append(-1, "&What","Is is the What the part of WTF")
theItem = wtfMenu.Append(-1,"&The","Is the THE part of WTF")
fukItem = wtfMenu.Append(-1,"&Fuk","Is the FUK park of WTF")
# the run menu
runMenu = wx.Menu()
# Now a help menu for the about item
helpMenu = wx.Menu()
aboutItem = helpMenu.Append(wx.ID_ABOUT)
# Make the menu bar and add the two menus to it. The '&' defines
# that the next letter is the "mnemonic" for the menu item. On the
# platforms that support it those letters are underlined and can be
# triggered from the keyboard.
menuBar = wx.MenuBar()
menuBar.Append(fileMenu, "&File")
menuBar.Append(wtfMenu, "&WTF")
menuBar.Append(runMenu, "&Run")
menuBar.Append(helpMenu, "&Help")
# Give the menu bar to the frame
self.SetMenuBar(menuBar)
# Finally, associate a handler function with the EVT_MENU event for
# each of the menu items. That means that when that menu item is
# activated then the associated handler function will be called.
self.Bind(wx.EVT_MENU, self.OnHello, helloItem)
self.Bind(wx.EVT_MENU, self.OnExit, exitItem)
self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)
self.Bind(wx.EVT_MENU, self.OnFuk, fukItem)
def OnExit(self, event):
"""Close the frame, terminating the application."""
self.Close(True)
def OnHello(self, event):
"""Say hello to the user."""
wx.MessageBox("Hello again from wxPython")
def OnAbout(self, event):
"""Display an About Dialog"""
wx.MessageBox("This is a wxPython Hello World sample that I entered in.",
"About Hello World 2.",
wx.OK|wx.ICON_INFORMATION)
def OnFuk(self, event):
''' Fuk menu has been selected. '''
# I want to open a inputbox and get some text from the user and update the window
myIpDlg = wx.TextEntryDialog(frm, 'Enter some text plese:','Input Please')
myIpDlg.SetValue("Default")
if myIpDlg.ShowModal() == wx.ID_OK:
print("You entered %s\n" % myIpDlg.GetValue())
myIpDlg.Destroy()
def buttonHasBeenPressed(event):
# So this code should be run when I press the button
wx.MessageBox("You Pressed my button")
if __name__ == '__main__':
# When this module is run (not imported) then create the app, the
# frame, show it, and start the event loop.
app = wx.App()
frm = HelloFrame(None, title='Hello World 2')
frm.Show()
frm.Bind(wx.EVT_BUTTON, buttonHasBeenPressed)
app.MainLoop()