Esempio n. 1
0
    def make_button(self, name, wtyp, icon=None, tooltip=None):
        picon = None
        if icon:
            iconfile = os.path.join(self.iconpath, '%s.png' % icon)
            try:
                image = QImage(iconfile)
                pixmap = QPixmap.fromImage(image)
                picon = QIcon(pixmap)
                qsize = QtCore.QSize(24, 24)
            except Exception as e:
                self.logger.error("Error loading icon '%s': %s" %
                                  (iconfile, str(e)))

        if wtyp == 'button':
            if picon:
                w = Widgets.Button()
                _w = w.get_widget()
                _w.setIconSize(qsize)
                _w.setIcon(picon)
            else:
                w = Widgets.Button(name)
        elif wtyp == 'toggle':
            if picon:
                w = Widgets.ToggleButton()
                _w = w.get_widget()
                _w.setIconSize(qsize)
                _w.setIcon(picon)
            else:
                w = Widgets.ToggleButton()

        return w
Esempio n. 2
0
 def make_button(self, name, wtyp, icon=None, tooltip=None):
     picon = None
     if icon:
         iconfile = os.path.join(self.iconpath, '%s.png' % icon)
         try:
             image = QtGui.QImage(iconfile)
             pixmap = QtGui.QPixmap.fromImage(image)
             picon = QtGui.QIcon(pixmap)
             qsize = QtCore.QSize(24, 24)
         except Exception, e:
             self.logger.error("Error loading icon '%s': %s" %
                               (iconfile, str(e)))
Esempio n. 3
0
 def add_action(self, text, toggle=False, iconpath=None):
     child = ToolbarAction()
     if iconpath:
         image = QImage(iconpath)
         qsize = QtCore.QSize(24, 24)
         image = image.scaled(qsize)
         pixmap = QPixmap.fromImage(image)
         iconw = QIcon(pixmap)
         action = self.widget.addAction(iconw, text, child._cb_redirect)
     else:
         action = self.widget.addAction(text, child._cb_redirect)
     action.setCheckable(toggle)
     child.widget = action
     self.add_ref(child)
     return child
Esempio n. 4
0
 def sizeHint(self):
     width, height = 300, 300
     if self.viewer is not None:
         width, height = self.viewer.get_desired_size()
     return QtCore.QSize(width, height)
Esempio n. 5
0
 def sizeHint(self):
     width, height = 300, 300
     if self.fitsimage != None:
         width, height = self.fitsimage.get_desired_size()
     return QtCore.QSize(width, height)
Esempio n. 6
0
 def sizeHint(self):
     return QtCore.QSize(100, 100)