diff --git a/gui/cadbiom_gui/gt_gui/chart_misc_widgets.py b/gui/cadbiom_gui/gt_gui/chart_misc_widgets.py index e3327644eeeb5ac9cfbc69d90de2229381bade27..8f3470e75674a8380a7aa5d5e5098c401de20167 100644 --- a/gui/cadbiom_gui/gt_gui/chart_misc_widgets.py +++ b/gui/cadbiom_gui/gt_gui/chart_misc_widgets.py @@ -311,17 +311,16 @@ class SearchFrontier(SearchManager): self.sn_viewer.refresh([]) - class LegendWindow(object): """ Widget to display the legend """ def __init__(self, parent=None): - self.win = gtk.Window() self.win.set_title("CADBIOM-Chart Legend") self.win.set_position(gtk.WIN_POS_CENTER) self.win.connect("destroy", self.on_destroy) + self.win.connect('key_press_event', self.on_escape) image = gtk.Image() template = pkg_resources.resource_filename( __name__, @@ -352,6 +351,13 @@ class LegendWindow(object): if self.win: self.win.destroy() + def on_escape(self, widget, event): + """On ESC key_press_event, destroy this window.""" + if gtk.gdk.keyval_name(event.keyval) == "Escape": + self.destroy() + return False + + class ImportPIDParam(object): """ Widget for model importing @@ -373,8 +379,13 @@ class ImportPIDParam(object): hei = int(hei * 0.20) self.main_window.set_size_request(350, hei) - if (self.main_window): + # Set modal mode for the window (above all windows & block inputs) + self.main_window.set_modal(True) + self.main_window.set_transient_for(parent) + + if self.main_window: self.main_window.connect("destroy", self.on_destroy) + self.main_window.connect('key_press_event', self.on_escape) self.main_window.set_position(gtk.WIN_POS_CENTER) @@ -473,6 +484,12 @@ class ImportPIDParam(object): """ self.on_destroy(None) + def on_escape(self, widget, event): + """On ESC key_press_event, destroy this window.""" + if gtk.gdk.keyval_name(event.keyval) == "Escape": + self.destroy() + return False + class ImportBioPAXParams(object): """ @@ -520,8 +537,9 @@ class ImportBioPAXParams(object): self.main_window.set_modal(True) self.main_window.set_transient_for(parent) - if (self.main_window): + if self.main_window: self.main_window.connect("destroy", self.on_destroy) + self.main_window.connect('key_press_event', self.on_escape) # Init interface # Triplestore @@ -673,3 +691,9 @@ class ImportBioPAXParams(object): for parents """ self.on_destroy(None) + + def on_escape(self, widget, event): + """On ESC key_press_event, destroy this window.""" + if gtk.gdk.keyval_name(event.keyval) == "Escape": + self.destroy() + return False diff --git a/gui/cadbiom_gui/gt_gui/charter.py b/gui/cadbiom_gui/gt_gui/charter.py index c4e060279ff2732cbd613c0864da1ed12ffc573e..b03f8519bed96d4267db760365867b026a90122c 100644 --- a/gui/cadbiom_gui/gt_gui/charter.py +++ b/gui/cadbiom_gui/gt_gui/charter.py @@ -639,12 +639,14 @@ class Charter(object): """ open a window to search xml file coming from PID database """ - ImportPIDParam(self) + # Pass the parent window to set modal mode on the child + ImportPIDParam(self, self.main_window) def choose_BioPAX_file(self, widget): """ open a window to import BioPAX data from a triplestore """ + # Pass the parent window to set modal mode on the child ImportBioPAXParams(self, self.main_window) def export_to_lang(self, widget): @@ -681,7 +683,7 @@ class Charter(object): """ Doc """ - self.legend = LegendWindow(self.current_edit_mvc) + self.legend = LegendWindow(self) def export_picture(self, widget): """