@@ -125,6 +125,14 @@ def file_select():
125
125
126
126
root .after (2000 , next_steps (identified_pii , dataset , datap_functions_conn , datap_messages_conn , tkinter_functions_conn , tkinter_messages_conn ))
127
127
128
+ def about ():
129
+ import webbrowser
130
+ webbrowser .open ('https://github.com/PovertyAction/PII_detection/blob/master/README.md#pii_detection' )
131
+
132
+ def contact ():
133
+ import webbrowser
134
+ webbrowser .open ('https://github.com/PovertyAction/PII_detection/issues' )
135
+
128
136
def next_steps (identified_pii , dataset , datap_functions_conn , datap_messages_conn , tkinter_functions_conn , tkinter_messages_conn ):
129
137
### Date Detection ###
130
138
tkinter_display ('in next steps' )
@@ -144,6 +152,16 @@ def next_steps(identified_pii, dataset, datap_functions_conn, datap_messages_con
144
152
### Exit Gracefully ###
145
153
# Consider adding option to restart script.
146
154
tkinter_display ('Processing complete.' )
155
+ Button (root , text = "Run Again" , command = restart_program ).pack ()
156
+
157
+
158
+ def restart_program ():
159
+ """Restarts the current program.
160
+ Note: this function does not return. Any cleanup action (like
161
+ saving data) must be done before calling this function."""
162
+ import os
163
+ python = sys .executable
164
+ os .execl (python , python , * sys .argv )
147
165
148
166
149
167
if __name__ == '__main__' :
@@ -156,11 +174,31 @@ def next_steps(identified_pii, dataset, datap_functions_conn, datap_messages_con
156
174
my_gui = GUI (root ) # runs code in class GUI
157
175
158
176
# Styles
159
- root .configure (background = 'light gray' )
177
+ menubar = tkinter .Menu (root )#.pack()
178
+
179
+ # create a pulldown menu, and add it to the menu bar
180
+ filemenu = Menu (menubar , tearoff = 0 )
181
+ filemenu .add_command (label = "Restart" , command = restart_program )
182
+ #filemenu.add_command(label="Save", command=hello)
183
+ filemenu .add_separator ()
184
+ filemenu .add_command (label = "Exit" , command = root .quit )
185
+ menubar .add_cascade (label = "File" , menu = filemenu )
186
+
187
+ # create more pulldown menus
188
+ helpmenu = Menu (menubar , tearoff = 0 )
189
+ helpmenu .add_command (label = "About" , command = about )
190
+ helpmenu .add_command (label = "File Issue on GitHub" , command = contact )
191
+ menubar .add_cascade (label = "Help" , menu = helpmenu )
192
+
193
+ root .configure (background = 'light gray' , menu = menubar )
160
194
root .style = ttk .Style ()
161
195
# root.style.theme_use("clam") # ('winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative')
162
196
root .style .configure ('my.TButton' , font = ("Calibri" , 11 , 'bold' ), background = 'white' )
163
197
root .style .configure ('my.TLabel' , background = 'white' )
198
+ root .style .configure ('my.TCheckbutton' , background = 'white' )
199
+ root .style .configure ('my.TMenubutton' , background = 'white' )
200
+
201
+ root .resizable (False , False ) # prevents window from being resized
164
202
165
203
# Display
166
204
@@ -191,36 +229,38 @@ def onFrameConfigure(canvas):
191
229
ttk .Label (frame , text = app_title , wraplength = 536 , justify = LEFT , font = ("Calibri" , 13 , 'bold' ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (30 , 10 ))
192
230
ttk .Label (frame , text = intro_text , wraplength = 546 , justify = LEFT , font = ("Calibri" , 11 ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 12 ))
193
231
ttk .Label (frame , text = intro_text_p2 , wraplength = 546 , justify = LEFT , font = ("Calibri" , 11 ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 30 ))
232
+
233
+ ttk .Label (frame , text = "Start Application:" , wraplength = 546 , justify = LEFT , font = ("Calibri" , 12 , 'bold' ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 10 ))
194
234
ttk .Button (frame , text = "Select Dataset" , command = file_select , style = 'my.TButton' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 30 ))
195
235
236
+ ttk .Label (frame , text = "Options:" , justify = LEFT , font = ("Calibri" , 12 , 'bold' ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 10 ))
237
+
238
+ # Dropdown
239
+
240
+ ttk .Label (frame , text = "Select Detection Sensitivity:" , justify = LEFT , font = ("Calibri" , 11 ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 ,0 ))
241
+
242
+ sensitivity = StringVar (frame )
243
+ w = ttk .OptionMenu (frame , sensitivity , "Medium (Default)" , "Maximum" , "High" , "Medium (Default)" , "Low" , "Minimum" , style = 'my.TMenubutton' ).pack (anchor = 'nw' , padx = (30 ,0 ))
244
+ # A combobox may be a better choice
245
+
196
246
# Checkbox
197
247
198
- # checkTemp = IntVar() #IntVar only necessary if I need app to change upon being checked
248
+ # checkTemp = IntVar() #IntVar only necessary if need app to change upon being checked
199
249
# checkTemp.set(0)
200
250
# checkCmd.get() == 0 # tests if unchecked, = 1 if checked
201
251
202
252
checkTemp = 0
253
+ checkBox1 = ttk .Checkbutton (frame , variable = checkTemp , onvalue = 1 , offvalue = 0 , text = "Output Session Log" , style = 'my.TCheckbutton' ).pack (anchor = 'nw' , padx = (30 , 0 ), pady = (10 ,0 ), fill = X )
203
254
204
- checkBox1 = Checkbutton (frame , variable = checkTemp , onvalue = 1 , offvalue = 0 , text = "Output Log" ).pack (anchor = 'nw' , padx = (30 , 30 ))
205
-
206
- # Dropdown
207
-
208
- sensitivity = StringVar (frame )
209
- sensitivity .set ("Medium (Default)" ) # default value
210
-
211
- w = OptionMenu (frame , sensitivity , "Maximum" , "High" , "Medium (Default)" , "Low" , "Minimum" ).pack (anchor = 'nw' , padx = (30 ,30 ))
255
+ ttk .Label (frame , text = "Status:" , justify = LEFT , font = ("Calibri" , 12 , 'bold' ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 ,0 ), pady = (30 , 0 ))
256
+ first_message = "Awaiting dataset selection."
257
+ first_message = datetime .now ().strftime ("%H:%M:%S" ) + ' ' + first_message
258
+ ttk .Label (frame , text = first_message , wraplength = 546 , justify = LEFT , font = ("Calibri Italic" , 11 ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 12 ))
212
259
213
260
# Listener
214
261
215
262
root .mainloop () # constantly looping event listener
216
263
217
- try :
218
- if len (messages_pipe ) != 0 :
219
- ttk .Label (frame , text = messages_pipe .get (), wraplength = 546 , justify = LEFT , font = ("Calibri" , 11 ), style = 'my.TLabel' ).pack (anchor = 'nw' , padx = (30 , 30 ), pady = (0 , 30 ))
220
- except NameError :
221
- pass
222
-
223
-
224
264
# Extra code
225
265
226
266
# ### Implement this for improvements to formatting
0 commit comments