forked from M-Labs/artiq
1
0
Fork 0

gui/shortcuts: fix status bar usage

This commit is contained in:
Sebastien Bourdeauducq 2015-12-01 18:22:12 +08:00
parent bbabc7bb8d
commit f73c967b3e
2 changed files with 7 additions and 10 deletions

View File

@ -100,7 +100,7 @@ def main():
sub_clients["schedule"], sub_clients["schedule"],
rpc_clients["schedule"]) rpc_clients["schedule"])
smgr.register(expmgr) smgr.register(expmgr)
d_shortcuts = shortcuts.ShortcutsDock(win, status_bar, expmgr) d_shortcuts = shortcuts.ShortcutsDock(win, expmgr)
smgr.register(d_shortcuts) smgr.register(d_shortcuts)
d_explorer = explorer.ExplorerDock(status_bar, expmgr, d_shortcuts, d_explorer = explorer.ExplorerDock(status_bar, expmgr, d_shortcuts,
sub_clients["explist"], sub_clients["explist"],

View File

@ -14,12 +14,11 @@ logger = logging.getLogger(__name__)
class ShortcutsDock(dockarea.Dock): class ShortcutsDock(dockarea.Dock):
def __init__(self, main_window, status_bar, exp_manager): def __init__(self, main_window, exp_manager):
dockarea.Dock.__init__(self, "Shortcuts", size=(1000, 300)) dockarea.Dock.__init__(self, "Shortcuts", size=(1000, 300))
self.layout.setSpacing(5) self.layout.setSpacing(5)
self.layout.setContentsMargins(5, 5, 5, 5) self.layout.setContentsMargins(5, 5, 5, 5)
self.status_bar = status_bar
self.exp_manager = exp_manager self.exp_manager = exp_manager
self.shortcut_widgets = dict() self.shortcut_widgets = dict()
@ -70,16 +69,12 @@ class ShortcutsDock(dockarea.Dock):
expname = self.shortcut_widgets[nr]["label"].text() expname = self.shortcut_widgets[nr]["label"].text()
if expname: if expname:
try: try:
rid = self.exp_manager.submit(expname) self.exp_manager.submit(expname)
except: except:
self.status_bar.showMessage("Could not submit experiment '{}'" # May happen when experiment has been removed
.format(expname)) # from repository/explist
logger.warning("failed to submit experiment %s", logger.warning("failed to submit experiment %s",
expname, exc_info=True) expname, exc_info=True)
else:
self.status_bar.showMessage("Submitted RID {} "
"(from global shortcut)"
.format(rid))
def _open_experiment(self, nr): def _open_experiment(self, nr):
expname = self.shortcut_widgets[nr]["label"].text() expname = self.shortcut_widgets[nr]["label"].text()
@ -87,6 +82,8 @@ class ShortcutsDock(dockarea.Dock):
try: try:
self.exp_manager.open_experiment(expname) self.exp_manager.open_experiment(expname)
except: except:
# May happen when experiment has been removed
# from repository/explist
logger.warning("failed to open experiment %s", logger.warning("failed to open experiment %s",
expname, exc_info=True) expname, exc_info=True)