Esempio n. 1
0
 def paintEvent(self, QPaintEvent):
     super(CustomTabButton, self).paintEvent(QPaintEvent)
     painter = QPainter(self)
     painter.setFont(self.font())
     if self.icon != None:
         if isinstance(self.icon, basestring):
             icon = resource.get_pixmap(self.icon, scale=self.icon_size)
         elif isinstance(self.icon, QPixmap):
             icon = self.icon.scaled(self.icon_size, self.icon_size,
                                     Qt.KeepAspectRatio,
                                     Qt.SmoothTransformation)
         painter.drawPixmap(self.iconPos, icon)
     if self.labeltext != "":
         painter.drawText(self.textRect, Qt.AlignCenter, self.labeltext)
     if self.pulldown is not None or self.menu is not None:
         background = self.colorDict["background"]
         lum = get_lum(other_to_rgb(background))
         if lum < 0.5:
             pulldownicon = resource.get_pixmap("button",
                                                "arrow_down1_white.png",
                                                scale=self.pulldownSize)
         else:
             pulldownicon = resource.get_pixmap("button",
                                                "arrow_down1_darkgray.png",
                                                scale=self.pulldownSize)
         painter.drawPixmap(self.pulldownPos, pulldownicon)
Esempio n. 2
0
    def __init__(self, icon=None, text=None):
        super(LabelButton2, self).__init__()

        self.status = 0

        self.icon = icon
        if self.icon:
            self.setToolTip("%s" % self.icon)
            self.imagePixmap = resource.get_pixmap('player',
                                                   '%s.png' % (self.icon),
                                                   scale=ICON_SIZE)
            self.imageHoverPixmap = resource.get_pixmap('player',
                                                        '%s_hover.png' %
                                                        (self.icon),
                                                        scale=ICON_SIZE)
            self.imageClickedPixmap = resource.get_pixmap('player',
                                                          '%s_clicked.png' %
                                                          (self.icon),
                                                          scale=ICON_SIZE)
            self.setPixmap(self.imagePixmap)

        self.textStr = text
        self.textNormalStr = "<font color=white>%s</font>" % text
        self.textHoverStr = "<font color=#00A2FF>%s</font>" % text
        self.textClickedStr = "<font color=#0076BA>%s</font>" % text
        if self.textStr:
            self.setText(self.textNormalStr)
Esempio n. 3
0
    def __init__(self,
                 value,
                 text_list=[],
                 icon=None,
                 icon_size=40,
                 parent=None):
        """
        :param value: str
        :param text_list: [{'text':'', 'width':40}, {}]
        :param icon: str
        :param parent:
        """
        super(ChooseItem, self).__init__(parent)
        self.value = value

        self.masterLayout = QHBoxLayout()
        # if icon is not None:
        self.icon = QLabel()
        self.icon.setFixedSize(icon_size, icon_size)
        if icon is not None and os.path.exists(icon):
            self.icon.setPixmap(resource.get_pixmap(icon, scale=icon_size))
        self.masterLayout.addWidget(self.icon)
        if icon is not None:
            self.masterLayout.insertSpacing(0, 10)
            self.masterLayout.insertSpacing(2, 10)
        for text in text_list:
            label = QLabel(text['text'])
            if text['width'] is not None:
                label.setFixedWidth(text['width'])
            self.masterLayout.addWidget(label)
        self.masterLayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.masterLayout)
Esempio n. 4
0
 def apply_choose(self, choose):
     if choose:
         display_text = choose.display_text
         icon = choose.icon
         color = choose.color
         # print color
         self.textLabel.setText(display_text)
         if icon is not None and os.path.exists(icon):
             self.iconLabel.setPixmap(
                 resource.get_pixmap(icon, scale=self.iconSize))
         if color is not None:
             r, g, b, a = int10_to_rgb(color, max=255, alpha_index=0)
             # print r, g, b, a
             self.back.setStyleSheet(
                 'background:rgb({}, {}, {}, {})'.format(r, g, b, 100))
         self.setToolTip(choose.tooltip)
     else:
         self.textLabel.setText(choose)
Esempio n. 5
0
    def __init__(self, name, colorDict={}, scale=24):
        super(QLabelButton, self).__init__()

        self.normalbackcolor = colorDict["normalbackcolor"]
        self.hoverbackcolor = colorDict["hoverbackcolor"]
        self.clickbackcolor = colorDict["clickbackcolor"]

        self.normalcolor = colorDict["normalcolor"]
        self.hovercolor = colorDict["hovercolor"]
        self.clickcolor = colorDict["clickcolor"]

        if name.find("/") != -1:
            self.normalpixmap = resource.get_pixmap("%s_%s.png" %
                                                    (name, self.normalcolor),
                                                    scale=scale)
            self.hiverpixmap = resource.get_pixmap("%s_%s.png" %
                                                   (name, self.hovercolor),
                                                   scale=scale)
            self.clickpixmap = resource.get_pixmap("%s_%s.png" %
                                                   (name, self.clickcolor),
                                                   scale=scale)
        else:
            self.normalpixmap = resource.get_pixmap("button",
                                                    "%s_%s.png" %
                                                    (name, self.normalcolor),
                                                    scale=scale)
            self.hiverpixmap = resource.get_pixmap("button",
                                                   "%s_%s.png" %
                                                   (name, self.hovercolor),
                                                   scale=scale)
            self.clickpixmap = resource.get_pixmap("button",
                                                   "%s_%s.png" %
                                                   (name, self.clickcolor),
                                                   scale=scale)

        # self.setToolTip(name)
        self.setPixmap(self.normalpixmap)
        self.setStyleSheet("background-color: %s" % self.normalbackcolor)
        self.setAlignment(Qt.AlignCenter)
        self.setFixedSize(scale, scale)
Esempio n. 6
0
 def draw_button(self, painter):
     point1 = [(self.width() - 50) / 2, (self.height() - 50) / 2]
     image = resource.get_pixmap("button", "playButton_blue.png", scale=50)
     painter.drawPixmap(QPoint(point1[0], point1[1]), image)
Esempio n. 7
0
 def set_image(self, image_path):
     self.current_image = image_path
     self.imageLabel.setPixmap(
         resource.get_pixmap(image_path, scale=[IMAGE_WIDTH, IMAGE_HEIGHT]))