コード例 #1
0
    def _construct_logwindow(self):
        def cb_logwindow_hideshow(logwindow):
            action = self.uimanager.get_action("/MainMenu/ViewMenu/ToggleLogwindow")
            action.set_active(logwindow.get_property("visible"))

        # logwindow is hidden by default. See _construct_uimanager if
        # you want to change this default
        logwindow = LogWindow()
        logwindow.set_transient_for(self)
        logwindow.set_destroy_with_parent(True)
        logwindow.hide()

        # logwindow specific
        def cb_toggle_logwindow(action, logwindow):
            if action.get_active() is True:
                logwindow.show()
            else:
                logwindow.hide()

        t = gtk.ToggleAction("ToggleLogwindow", "Show debug window", None, None)
        t.connect("toggled", cb_toggle_logwindow, logwindow)
        uihelper.get_action_group(self.uimanager, "Application").add_action(t)

        logwindow.connect("hide", cb_logwindow_hideshow)
        logwindow.connect("show", cb_logwindow_hideshow)

        return logwindow
コード例 #2
0
    def _construct_logwindow(self):

        def cb_logwindow_hideshow(window, action):
            action.set_active(window.get_property('visible'))

        # logwindow is hidden by default. See _construct_uimanager if
        # you want to change this default
        logwindow = LogWindow()
        logwindow.set_transient_for(self)
        logwindow.set_destroy_with_parent(True)
        logwindow.hide()

        # logwindow specific
        def cb_toggle_logwindow(action, logwindow):
            if action.get_active() is True: logwindow.show()
            else: logwindow.hide()

        t = gtk.ToggleAction('ToggleLogwindow', 'Show debug window', None, None)
        t.connect("toggled", cb_toggle_logwindow, logwindow)
        uihelper.get_action_group(self.uimanager, 'Application').add_action(t)

        logwindow.connect('hide', cb_logwindow_hideshow, t)
        logwindow.connect('show', cb_logwindow_hideshow, t)
        
        return logwindow
コード例 #3
0
    def _construct_toolwindow(self):

        window = tools.ToolWindow(self.app, None)
        window.set_transient_for(self)
        window.set_destroy_with_parent(True)
        window.hide()

        def cb_toggle_window(action, window):
            if action.get_active() is True: window.show()
            else: window.hide()        
        t = gtk.ToggleAction('ToggleToolWindow', 'Show tools window', None, None)
        t.connect("toggled", cb_toggle_window, window)
        uihelper.get_action_group(self.uimanager, 'Application').add_action(t)

        def cb_window_hideshow(window):
            action = self.uimanager.get_action('/MainMenu/ViewMenu/ToggleToolWindow')
            action.set_active(window.get_property('visible'))
        window.connect('hide', cb_window_hideshow)
        window.connect('show', cb_window_hideshow)

        def on_notify_project(sender, project, toolwin):
            print "==> project = ", project
            print "==> toolwin = ", toolwin
            toolwin.set_project(project)
        Signals.connect(self.app, 'notify::project', on_notify_project, window)
        
        return window
コード例 #4
0
    def _refresh_windowlist(self):

        # We are going to recreate the actiongroup 'WindowList'.
        # To avoid adding this actiongroup multiple times, we need
        # to remove it first.
        if self._windowlist_merge_id is not None:
            ag = uihelper.get_action_group(self.uimanager, "WindowList")
            self.uimanager.remove_action_group(ag)
            self.uimanager.remove_ui(self._windowlist_merge_id)

        # create action groups list from windowlist
        ag = gtk.ActionGroup("WindowList")
        for window in self._windows:
            title = window.get_title() or "noname"
            logger.debug("Window title is %s" % title)
            action = gtk.Action(id(window), title, None, None)
            action.connect("activate", self._cb_subwindow_present, window)
            ag.add_action(action)
        self.uimanager.insert_action_group(ag, 0)

        # create ui description from available actions
        ui = "<ui><menubar name='MainMenu'><menu action='ViewMenu'>\n"
        for window in self._windows:
            ui += "<menuitem action='%s'/>\n" % id(window)
        ui += "</menu></menubar></ui>"

        self._windowlist_merge_id = self.uimanager.add_ui_from_string(ui)
コード例 #5
0
    def _refresh_windowlist(self):      

        # We are going to recreate the actiongroup 'WindowList'.
        # To avoid adding this actiongroup multiple times, we need
        # to remove it first.
        if self._windowlist_merge_id is not None:
            ag = uihelper.get_action_group(self.uimanager, "DynamicWindowList")
            self.uimanager.remove_action_group(ag)
            self.uimanager.remove_ui(self._windowlist_merge_id)
            
        # Create action groups list from windowlist.
        # The corresponding ui string is created as well.
        ui = ""
        ag =  gtk.ActionGroup('DynamicWindowList')
        for window in self._windows:            
            title = window.get_title() or "noname"
            logger.debug("Window title is %s" % title)
            action = gtk.Action(id(window), title, None, None)
            action.connect('activate', self._cb_subwindow_present, window)
            ag.add_action(action)
            ui+="<menuitem action='%s'/>\n" % id(window)
        self.uimanager.insert_action_group(ag,0)

        # Wrap UI description.
        ui="""
        <ui>
          <menubar name='MainMenu'>
            <menu action='ViewMenu'>
            %s
            </menu>
          </menubar>
        </ui>
        """ % ui
                       
        self._windowlist_merge_id = self.uimanager.add_ui_from_string(ui)                      
コード例 #6
0
    def _construct_toolbox(self):

        window = tools.Toolbox(self.app, None)
        window.set_transient_for(self)
        window.set_destroy_with_parent(True)
        window.hide()

        def cb_toggle_window(action, window):
            if action.get_active() is True: window.show()
            else: window.hide()        
        t = gtk.ToggleAction('ToggleToolbox', 'Show tools window', None, None)
        t.connect("toggled", cb_toggle_window, window)
        uihelper.get_action_group(self.uimanager, 'Application').add_action(t)

        def on_window_visibility_toggled(window, action):
            action.set_active(window.get_property('visible'))
        window.connect('hide', on_window_visibility_toggled, t)
        window.connect('show', on_window_visibility_toggled, t)

        def on_notify_project(sender, project, toolwin):
            toolwin.set_project(project)
        self.app.sig_connect('notify::project', on_notify_project, window)
        
        return window
コード例 #7
0
    def _refresh_recentfiles(self):
       
        # remove last recent files
        if self._recentfiles_merge_id is not None:
            ag = uihelper.get_action_group(self.uimanager, "DynamicRecentFiles")
            self.uimanager.remove_action_group(ag)
            self.uimanager.remove_ui(self._recentfiles_merge_id)

        # Create action group list from list of recent files.
        # The corresponding ui string is created as well.
        ui = ""
        n = 0
        ag = gtk.ActionGroup('DynamicRecentFiles')
        for file in self.app.recent_files:
            key = 'recent_files_%d' % n
            action = gtk.Action(key, '%d: %s' % (n, os.path.basename(file)), None, None)
            action.connect('activate',
                           (lambda sender, filename: self.app.load_project(filename)),
                           file)
            ag.add_action(action)
            
            ui+="<menuitem action='%s'/>\n" % key
            n += 1
            
        self.uimanager.insert_action_group(ag, 0)

        # Wrap UI description.
        ui="""
        <ui>
          <menubar name='MainMenu'>
            <menu action='FileMenu'>
              <menu action='RecentFilesMenu'>
                <placeholder name='RecentFilesList'>
                  %s
                </placeholder>
               </menu>
             </menu>
          </menubar>
        </ui>
        """ % ui
            
        self._recentfiles_merge_id = self.uimanager.add_ui_from_string(ui)
コード例 #8
0
    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)))
コード例 #9
0
    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()))