@@ -64,19 +64,42 @@ def _on_tab_changed(self,event):
6464 style .theme_create ("custom" , parent = "alt" , settings = settings )
6565 style .theme_use ("custom" )
6666
67- def dummy ():
68- pass
67+ def run ():
68+ options = {}
69+
70+ for key in window ._widgets :
71+ dest , type = key
72+ widget = window ._widgets [key ]
73+
74+ if hasattr (widget , "get" ) and not widget .get ():
75+ value = None
76+ elif type == "string" :
77+ value = widget .get ()
78+ elif type == "float" :
79+ value = float (widget .get ())
80+ elif type == "int" :
81+ value = int (widget .get ())
82+ else :
83+ value = bool (widget .getint ())
84+
85+ options [dest ] = value
86+
87+ for option in parser .option_list :
88+ options [option .dest ] = defaults .get (option .dest , None )
89+
90+ parser ._args = options
91+ window .destroy ()
6992
7093 menubar = tkinter .Menu (window )
7194
7295 filemenu = tkinter .Menu (menubar , tearoff = 0 )
73- filemenu .add_command (label = "Open" , command = dummy , state = tkinter .DISABLED )
74- filemenu .add_command (label = "Save" , command = dummy , state = tkinter .DISABLED )
96+ filemenu .add_command (label = "Open" , state = tkinter .DISABLED )
97+ filemenu .add_command (label = "Save" , state = tkinter .DISABLED )
7598 filemenu .add_separator ()
7699 filemenu .add_command (label = "Exit" , command = window .quit )
77100 menubar .add_cascade (label = "File" , menu = filemenu )
78101
79- menubar .add_command (label = "Run" , command = window . quit )
102+ menubar .add_command (label = "Run" , command = run )
80103
81104 helpmenu = tkinter .Menu (menubar , tearoff = 0 )
82105 helpmenu .add_command (label = "Official site" , command = lambda : webbrowser .open (SITE ))
@@ -88,11 +111,13 @@ def dummy():
88111 menubar .add_cascade (label = "Help" , menu = helpmenu )
89112
90113 window .config (menu = menubar )
114+ window ._widgets = {}
91115
92116 notebook = AutoresizableNotebook (window )
93117
94118 first = None
95119 frames = {}
120+
96121 for group in parser .option_groups :
97122 frame = frames [group .title ] = tkinter .Frame (notebook , width = 200 , height = 200 )
98123 notebook .add (frames [group .title ], text = group .title )
@@ -122,6 +147,8 @@ def dummy():
122147 first = first or widget
123148 widget .grid (column = 1 , row = row , sticky = tkinter .W )
124149
150+ window ._widgets [(option .dest , option .type )] = widget
151+
125152 default = defaults .get (option .dest )
126153 if default :
127154 if hasattr (widget , "insert" ):
0 commit comments