-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
145 lines (77 loc) · 5.38 KB
/
Copy pathmain.py
File metadata and controls
145 lines (77 loc) · 5.38 KB
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
139
140
import wx
# Create the App window and Panel
app = wx.App()
window = wx.Frame(None, title = "Math Worksheet Generator", size = (1885, 1010))
window.Show()
bkg = wx.Panel(window, style = wx.WANTS_CHARS)
# Define 4 basic sizers: three horizontal sizers and a vertical one. Set the vertical sizer as base
base_vertical_sizer = wx.BoxSizer(wx.VERTICAL)
top_horizontal_sizer = wx.BoxSizer(wx.HORIZONTAL)
middle_horizontal_sizer = wx.BoxSizer(wx.HORIZONTAL)
bottom_horizontal_sizer = wx.BoxSizer(wx.HORIZONTAL)
bkg.SetSizer(base_vertical_sizer)
# Nest the three horizontal sizers within the vertical one
base_vertical_sizer.Add(top_horizontal_sizer, proportion = 1, flag = wx.TOP | wx.EXPAND, border = 10)
base_vertical_sizer.Add(middle_horizontal_sizer, proportion = 1, border = 10)
base_vertical_sizer.Add(bottom_horizontal_sizer, proportion = 1, flag = wx.BOTTOM | wx.EXPAND, border = 10)
# Construct the top horizontal box sizer, with one horizontal bar and the "run" button.
text_bar_label = wx.StaticText(bkg, label="Enter the message you wish the math problems to spell: ")
text_bar = wx.TextCtrl(bkg, pos = (0, 35), size = (210, 25), style = wx.WANTS_CHARS)
run_button = wx.Button(bkg, label = "RUN", pos = (500, 30), size = (120, 25))
top_horizontal_sizer.Add(text_bar_label, proportion = 0, flag = wx.LEFT, border = 5)
top_horizontal_sizer.Add(text_bar, proportion = 1, border = 5)
top_horizontal_sizer.Add(run_button, proportion = 0, flag = wx.RIGHT, border = 5)
# Construct the radio-button portion of the middle horizontal sizer
language_buttons_vertical_sizer = wx.BoxSizer(wx.VERTICAL)
french_button = wx.RadioButton(bkg,11, label = 'French', pos = (10,10), style = wx.RB_GROUP)
english_button = wx.RadioButton(bkg,22, label = 'English',pos = (10,40))
language_buttons_vertical_sizer.Add(french_button, proportion = 1, border = 5)
language_buttons_vertical_sizer.Add(english_button, proportion = 1, border = 5)
middle_horizontal_sizer.Add(language_buttons_vertical_sizer, proportion = 1, border = 5, flag = wx.TOP | wx.LEFT)
# Construct the checkbox portion of the middle horizontal sizer. It contains two horizontal sizers nested within a vertical one, which is added to the middle horizontal sizer
operator_buttons_vertical_sizer = wx.BoxSizer(wx.VERTICAL)
operator_buttons_horizontal_sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
addition_button = wx.CheckBox(bkg, label = '+ ',pos = (10,10))
subtraction_button = wx.CheckBox(bkg, label = '- ',pos = (10,10))
operator_buttons_horizontal_sizer_1.Add(addition_button, proportion = 1, border = 5, flag = wx.LEFT)
operator_buttons_horizontal_sizer_1.Add(subtraction_button, proportion = 1, border = 5, flag = wx.RIGHT)
operator_buttons_horizontal_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
multiplication_button = wx.CheckBox(bkg, label = '× ',pos = (10,10))
division_button = wx.CheckBox(bkg, label = '÷ ',pos = (10,10))
operator_buttons_horizontal_sizer_2.Add(multiplication_button, proportion = 1, border = 5, flag = wx.LEFT)
operator_buttons_horizontal_sizer_2.Add(division_button, proportion = 1, border = 5, flag = wx.RIGHT)
operator_buttons_vertical_sizer.Add(operator_buttons_horizontal_sizer_1, proportion = 1, border = 5, flag = wx.TOP)
operator_buttons_vertical_sizer.Add(operator_buttons_horizontal_sizer_2, proportion = 1, border = 5, flag = wx.BOTTOM)
middle_horizontal_sizer.Add(operator_buttons_vertical_sizer, proportion = 1, border = 5, flag = wx.RIGHT)
# Construct the lower horizontal box
text_box = wx.TextCtrl(bkg, pos = (10, 35), size = (50, 550), style = wx.TE_MULTILINE | wx.HSCROLL | wx.WANTS_CHARS | wx.VSCROLL)
bottom_horizontal_sizer.Add(text_box, proportion = 1, border = 5)
'https://www.tutorialspoint.com/wxpython/wxpython_buttons.htm'
'https://www.tutorialspoint.com/wxpython/wx_checkbox_class.htm'
### GO! ###
app.MainLoop()
# outputbox = wx.TextCtrl(bkg, pos = (0, 35), size = (500, 400), style = wx.TE_MULTILINE | wx.HSCROLL | wx.WANTS_CHARS)
# contents.SetWindowStyle(contents.GetWindowStyle() & ~ wx.TAB_TRAVERSAL)
# outputbox.SetWindowStyle(outputbox.GetWindowStyle() & ~ wx.TAB_TRAVERSAL)
# loadButton = wx.Button(bkg, label = "import", pos = (500, 30), size = (120, 25))
# # Create the error box
# errorbox = wx.TextCtrl(bkg, pos = (10, 35), size = (50, 750), style = wx.TE_MULTILINE | wx.HSCROLL | wx.WANTS_CHARS | wx.VSCROLL)
# # And add them to a vertical box sizer
# buttonBox = wx.BoxSizer(wx.VERTICAL)
# buttonBox.Add(loadButton, proportion = 1, flag = wx.BOTTOM, border = 5)
# #Add the two text boxes and the button box to a new, horizontal box sizer representing all of the window below the command line
# lowerhbox = wx.BoxSizer(wx.HORIZONTAL)
# lowerhbox.Add(contents, proportion = 1, flag = wx.EXPAND | wx.BOTTOM | wx.LEFT, border = 5)
# lowerhbox.Add(outputbox, proportion = 1, flag = wx.EXPAND | wx.BOTTOM | wx.RIGHT, border = 5)
# lowerhbox.Add(buttonBox, proportion = 0, flag = wx.RIGHT, border = 10)
# # Add the command bar and the lower box to a vertical sizer, and set that as the main sizer
# command = wx.TextCtrl(bkg, pos = (5, 5), size = (210, 25))
# vbox = wx.BoxSizer(wx.VERTICAL)
# vbox.Add(command, proportion = 0, flag = wx.EXPAND | wx.TOP, border = 10)
# vbox.Add(lowerhbox, proportion = 1, flag = wx.EXPAND | wx.BOTTOM, border = 10)
# def openFunct(var):
# pass
# contents.SetValue("None")
# loadButton.Bind(wx.EVT_BUTTON, openFunct)
# command.SetValue("[Type commands here]")
# errorbox.SetValue("\n*****Status*****")