def __init__(self, app, project, plot): gtk.Window.__init__(self) self.set_default_size(640,480) #self.set_transient_for(app.window) self.is_fullscreen = False self.app = app self.disabled_groups = list() self.mpl_widget = MatplotlibWidget(app, project, plot) # set up ui manager self.uimanager = gtk.UIManager() # add undo/redo ui from application window ag = uihelper.get_action_group(self.app.window.uimanager, 'UndoRedo') self.uimanager.insert_action_group(ag,0) # add ui information from window for ag in uihelper.construct_actiongroups(self.actions_dict, map=self): self.uimanager.insert_action_group(ag,0) self.uimanager.add_ui_from_string(self.uistring) # add ui information from subwidget for ag in self.mpl_widget.get_actiongroups(): self.uimanager.insert_action_group(ag,0) self.uimanager.add_ui_from_string(self.mpl_widget.get_uistring()) # and set up accelerators for all of the above accel_group = self.uimanager.get_accel_group() self.add_accel_group(accel_group) # connect the ESC-key to the mpl widget's cancel button key, modifier = gtk.accelerator_parse('Escape') self.mpl_widget.btn_cancel.add_accelerator("activate", accel_group, key, modifier, gtk.ACCEL_VISIBLE) # construct menubar menubar = self.uimanager.get_widget('/MainMenu') menubar.show() # construct toolbar toolbar = self.uimanager.get_widget('/MainToolbar') toolbar.set_style(gtk.TOOLBAR_ICONS) toolbar.show() # put everything in a vertical box vbox = gtk.VBox() vbox.pack_start(menubar, False, True) vbox.pack_start(toolbar, False, True) vbox.pack_start(self.mpl_widget, True, True) self.add(vbox) #self.set_title( "Plot: %s" % plot.key ) self.mpl_widget.show() vbox.show() self.mpl_widget.connect("edit-mode-started", self.disable_interaction) self.mpl_widget.connect("edit-mode-ended", self.enable_interaction) self.connect("destroy", (lambda sender: self.destroy())) Signals.connect(self.mpl_widget, "closed", (lambda sender: self.destroy())) # TESTING self.connect("focus-in-event", (lambda a,b: app.set_current_plot(self.mpl_widget.plot)))
def __init__(self, app, project, plot): gtk.Window.__init__(self) self.set_default_size(640,480) self.is_fullscreen = False self.app = app self.disabled_groups = list() self.mpl_widget = MatplotlibWidget(app, project, plot) # set up ui manager self.uimanager = gtk.UIManager() # add undo/redo ui from application window ag = uihelper.get_action_group(self.app.window.uimanager, 'UndoRedo') self.uimanager.insert_action_group(ag,0) # add action group from window for ag in uihelper.construct_actiongroups(self.actions_dict, map=self): self.uimanager.insert_action_group(ag,0) # add action group for toolbox toolbox = self.app.window.toolbox def on_toggled(action, window): if action.get_active() is True: window.show() else: window.hide() t = gtk.ToggleAction('ToggleToolbox', 'Toolbox', 'ToggleToolbox visibility', gtk.STOCK_PROPERTIES) t.connect("toggled", on_toggled, toolbox) uihelper.get_action_group(self.uimanager, 'ViewMenu').add_action(t) t.set_active(toolbox.get_property('visible')) # ...and now that all action groups are created, # we can create the actual ui for the window self.uimanager.add_ui_from_string(self.uistring) # add ui information from subwidget for ag in self.mpl_widget.get_actiongroups(): self.uimanager.insert_action_group(ag,0) self.uimanager.add_ui_from_string(self.mpl_widget.get_uistring()) # and set up accelerators for all of the above accel_group = self.uimanager.get_accel_group() self.add_accel_group(accel_group) # connect the ESC-key to the mpl widget's cancel button key, modifier = gtk.accelerator_parse('Escape') self.mpl_widget.btn_cancel.add_accelerator("activate", accel_group, key, modifier, gtk.ACCEL_VISIBLE) # construct menubar menubar = self.uimanager.get_widget('/MainMenu') menubar.show() # construct toolbar toolbar = self.uimanager.get_widget('/MainToolbar') toolbar.set_style(gtk.TOOLBAR_ICONS) toolbar.show() # put everything in a vertical box vbox = gtk.VBox() vbox.pack_start(menubar, False, True) vbox.pack_start(toolbar, False, True) vbox.pack_start(self.mpl_widget, True, True) self.add(vbox) #self.set_title( "Plot: %s" % plot.key ) self.mpl_widget.show() vbox.show() self.mpl_widget.connect("edit-mode-started", self.disable_interaction) self.mpl_widget.connect("edit-mode-ended", self.enable_interaction) self.connect("destroy", (lambda sender: self.destroy())) Signals.connect(self.mpl_widget, "closed", (lambda sender: self.destroy()))