forked from M-Labs/artiq
1
0
Fork 0

gui: handle exit in explorer

This commit is contained in:
Sebastien Bourdeauducq 2015-01-27 23:51:23 +08:00
parent d2d07f29fe
commit 71c5115c11
2 changed files with 13 additions and 12 deletions

View File

@ -67,8 +67,12 @@ def main():
atexit.register( atexit.register(
lambda: loop.run_until_complete(parameters_win.sub_close())) lambda: loop.run_until_complete(parameters_win.sub_close()))
def exit(*args):
lmgr.save()
Gtk.main_quit(*args)
explorer_win = lmgr.create_window(ExplorerWindow, explorer_win = lmgr.create_window(ExplorerWindow,
"explorer", "explorer",
exit,
schedule_ctl, schedule_ctl,
repository) repository)
loop.run_until_complete(explorer_win.load_controls()) loop.run_until_complete(explorer_win.load_controls())
@ -76,11 +80,6 @@ def main():
parameters_win.show_all() parameters_win.show_all()
explorer_win.show_all() explorer_win.show_all()
def exit(*args):
lmgr.save()
Gtk.main_quit(*args)
explorer_win.connect("delete-event", exit)
rtr = RTResults() rtr = RTResults()
loop.run_until_complete(rtr.sub_connect( loop.run_until_complete(rtr.sub_connect(
args.server, args.port_notify)) args.server, args.port_notify))

View File

@ -6,7 +6,7 @@ from artiq.gui.tools import Window, getitem
class ExplorerWindow(Window): class ExplorerWindow(Window):
def __init__(self, schedule_ctl, repository, layout_dict=dict()): def __init__(self, exit_fn, schedule_ctl, repository, layout_dict=dict()):
self.schedule_ctl = schedule_ctl self.schedule_ctl = schedule_ctl
self.repository = repository self.repository = repository
@ -14,6 +14,7 @@ class ExplorerWindow(Window):
title="Explorer", title="Explorer",
default_size=(800, 570), default_size=(800, 570),
layout_dict=layout_dict) layout_dict=layout_dict)
self.connect("delete-event", exit_fn)
topvbox = Gtk.VBox(spacing=6) topvbox = Gtk.VBox(spacing=6)
self.add(topvbox) self.add(topvbox)
@ -23,13 +24,14 @@ class ExplorerWindow(Window):
windows = Gtk.MenuItem("Windows") windows = Gtk.MenuItem("Windows")
windows_menu = Gtk.Menu() windows_menu = Gtk.Menu()
scheduler = Gtk.MenuItem("Scheduler") menuitem = Gtk.MenuItem("Scheduler")
parameters = Gtk.MenuItem("Parameters") windows_menu.append(menuitem)
quit = Gtk.MenuItem("Quit") menuitem = Gtk.MenuItem("Parameters")
windows_menu.append(scheduler) windows_menu.append(menuitem)
windows_menu.append(parameters)
windows_menu.append(Gtk.SeparatorMenuItem()) windows_menu.append(Gtk.SeparatorMenuItem())
windows_menu.append(quit) menuitem = Gtk.MenuItem("Quit")
menuitem.connect("activate", exit_fn)
windows_menu.append(menuitem)
windows.set_submenu(windows_menu) windows.set_submenu(windows_menu)
menubar.append(windows) menubar.append(windows)