示例#1
0
def create_toolbutton(parent,
                      text=None,
                      shortcut=None,
                      icon=None,
                      tip=None,
                      toggled=None,
                      triggered=None,
                      autoraise=True,
                      text_beside_icon=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        QObject.connect(button, SIGNAL('clicked()'), triggered)
    if toggled is not None:
        QObject.connect(button, SIGNAL("toggled(bool)"), toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
示例#2
0
 def initialize_plugin(self):
     """Initialize plugin: connect signals, setup actions, ..."""
     self.plugin_actions = self.get_plugin_actions()
     QObject.connect(self, SIGNAL("show_message(QString,int)"), self.show_message)
     QObject.connect(self, SIGNAL("update_plugin_title()"), self.__update_plugin_title)
     if self.sig_option_changed is not None:
         self.sig_option_changed.connect(self.set_option)
     self.setWindowTitle(self.get_plugin_title())
     self.create_toggle_view_action()
示例#3
0
 def initialize_plugin(self):
     """Initialize plugin: connect signals, setup actions, ..."""
     self.plugin_actions = self.get_plugin_actions()
     QObject.connect(self, SIGNAL('show_message(QString,int)'),
                     self.show_message)
     QObject.connect(self, SIGNAL('update_plugin_title()'),
                     self.__update_plugin_title)
     if self.sig_option_changed is not None:
         self.sig_option_changed.connect(self.set_option)
     self.setWindowTitle(self.get_plugin_title())
     self.create_toggle_view_action()
示例#4
0
        def __init__(self, canvas, num):
            import matplotlib
            
            if backend_qt4.DEBUG:
                print 'FigureManagerQT.%s' % backend_qt4.fn_name()
            backend_qt4.FigureManagerBase.__init__(self, canvas, num)
            self.canvas = canvas
            
            self.window = FigureWindow()
            self.window.setWindowTitle("Figure %d" % num)
            self.window.setAttribute(Qt.WA_DeleteOnClose)

            import os.path as osp
            image = osp.join(matplotlib.rcParams['datapath'],
                             'images', 'matplotlib.png' )
            self.window.setWindowIcon(QIcon(image))
    
            # Give the keyboard focus to the figure instead of the manager
            self.canvas.setFocusPolicy(Qt.ClickFocus)
            self.canvas.setFocus()
    
            QObject.connect(self.window, SIGNAL('destroyed()'),
                            self._widgetclosed)
            self.window._destroying = False
    
            self.toolbar = self._get_toolbar(self.canvas, self.window)
            self.window.addToolBar(self.toolbar)
            QObject.connect(self.toolbar, SIGNAL("message"),
                    self.window.statusBar().showMessage)
    
            self.window.setCentralWidget(self.canvas)
    
            if matplotlib.is_interactive():
                self.window.show()
    
            # attach a show method to the figure for pylab ease of use
            self.canvas.figure.show = lambda *args: self.window.show()
    
            def notify_axes_change(fig):
                # This will be called whenever the current axes is changed
                if self.toolbar != None: self.toolbar.update()
            self.canvas.figure.add_axobserver(notify_axes_change)
示例#5
0
def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
                      toggled=None, triggered=None,
                      autoraise=True, text_beside_icon=False):
    """Create a QToolButton"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        QObject.connect(button, SIGNAL('clicked()'), triggered)
    if toggled is not None:
        QObject.connect(button, SIGNAL("toggled(bool)"), toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button