-
Notifications
You must be signed in to change notification settings - Fork 79
/
demo_converted_from_tk_v1.py
73 lines (55 loc) · 2.83 KB
/
demo_converted_from_tk_v1.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
# form converted from a tkinter example using 'Box'es for layout
# http://www.dreamincode.net/forums/topic/371440-tkinter-overview-with-a-fixed-width-grid/
from guizero import App, MenuBar, Text, TextBox, Combo, Slider, CheckBox, ButtonGroup, Box, PushButton, info, yesno
# Draw the form using 'guizero' wrapper for tkinter
app = App("Simple Window", 400, 300, layout="grid")
# Setup the functions needed by the GUI controls
def exit_function():
print("File option")
app.destroy()
def edit_function():
print("Edit option")
def do_salaryScale(slider_value):
salaryLabel.value = "Salary : "+str(slider_value)
def do_fullTimeCheckBox():
if fullTimeCheckBox.value == 1:
app.title=("Simple Window (full-time)")
else:
app.title=("Simple Window")
def do_jobButtonGroup():
jobTitleLabel.value = jobButtonGroup.value_text
def do_okPushButton():
info("Information", "Thank you!")
def do_closePushButton():
if yesno("Exit?", "Exit program?") == True:
app.destroy()
menubar = MenuBar(app,
toplevel=["File"],
options=[
[ ["Exit", exit_function] ]
])
# Layout the app controls
firstNameLabel = Text(app, text="First Name", grid=[0,0], align="left", size=10)
lastNameLabel = Text(app, text="Last Name", grid=[0,1], align="left", size=10)
countryLabel = Text(app, text="Country", grid=[0,2], align="left", size=10)
addressLabel = Text(app, text="Address", grid=[0,3], align="left", size=10)
firstNameText = TextBox(app, width=25, grid=[1,0])
lastNameText = TextBox(app, width=25, grid=[1,1])
countryCombo = Combo(app, options=['United Kingdom', 'United States', 'France'], selected='United Kingdom', grid=[1,2])
box = Box(app, grid=[1,3], layout="grid")
addressText1 = TextBox(box, width=25, grid=[0,0])
addressText2 = TextBox(box, width=25, grid=[0,1])
addressText3 = TextBox(box, width=25, grid=[0,2])
addressText4 = TextBox(box, width=25, grid=[0,3])
addressText5 = TextBox(box, width=25, grid=[0,4])
addressText6 = TextBox(box, width=25, grid=[0,5])
jobTitleLabel = Text(app, text="TBA", grid=[1,4], size=10)
salaryLabel = Text(app, text="Salary : ", grid=[2,0], align="left", size=10)
salaryScale = Slider(app, start=10000, end=100000, grid=[2,1], command=do_salaryScale, align="left")
fullTimeCheckBox = CheckBox(app, text="Full-time?", grid=[2,2], command=do_fullTimeCheckBox, align="left")
jobButtonGroup = ButtonGroup(app, options=["Programmer", "Developer", "Web Developer", "Designer"],
selected=0, grid=[2,3], command=do_jobButtonGroup, align="left")
box1 = Box(app, grid=[2,4], layout="grid", align="left")
okPushButton = PushButton(box1, text="OK", command=do_okPushButton, grid=[0,0], padx=5, pady=5)
closePushButton = PushButton(box1, text="Close", command=do_closePushButton, grid=[2,0], padx=5, pady=5)
app.display()