コード例 #1
0
 def registerWidget(self, id, name, description, factory):
     widget = WidgetConfigure()
     config = self.db.getWidgetConfig(id)
     if config is None:
         config = {}
         config["id"] = id
         config["left"] = 15
         config["top"] = 10
         config["width"] = 10
         config["height"] = 10
         config["enabled"] = False
         self.db.saveWidgetConfig(config)
         widget.rect = QRect(15, 10, 10, 10)
         widget.enabled = False
     else:
         widget.rect = QRect(config["left"], config["top"], config["width"], config["height"])
         widget.enabled = config["enabled"]
     widget.id = id
     widget.name = name
     widget.description = description
     widget.factory = factory
     widget.widget = None
     self.widgets.append(widget)
     if widget.enabled:
         self._enableWidget(widget, False)
コード例 #2
0
    def _arrange_data(self):

        self.rect = QRect()

        for i in range(len(self.pattern.coordinates)):

            coordinates = self.pattern.coordinates[i]
            colour_item = self.colourModel.item(i)

            lines = []
            xb, yb = [], []
            mx, my = 0, 0

            for op, x, y in coordinates:
                xb.append(x)
                yb.append(y)
                if op == "move":
                    mx, my = x, y
                elif op == "stitch":
                    line = QLine(mx, -my, x, -y)
                    lines.append(line)
                    mx, my = x, y

            xb = [min(xb), max(xb)]
            yb = [min(yb), max(yb)]
            rect = QRect(min(xb), -max(yb),
                         max(xb) - min(xb),
                         max(yb) - min(yb))
            self.rect = self.rect.united(rect)

            zone = Zone(rect, colour_item)
            zone.lines = lines
            self._partition_data(zone)
            self.zones.append(zone)
コード例 #3
0
 def verticalGradient(self, painter, spanRect, clipRect):
     key = 'fancy vertical gradient %d %d %d %d %d'%(spanRect.width(), spanRect.height(), clipRect.width(),
                                          clipRect.height(), self.baseColor.rgb())
     pixmap = QPixmap()
     p = painter
     rect = QRect(clipRect)
     
     if self._usePixmapCache and not QPixmapCache.find(key, pixmap):
         pixmap = QPixmap(clipRect.size())
         p = QPainter(pixmap)
         rect = QRect(0, 0, clipRect.width(), clipRect.height())
     
     base = self.baseColor
     grad = QLinearGradient(QPointF(spanRect.topRight()), QPointF(spanRect.topLeft()))
     grad.setColorAt(0, self.highlightColor)
     grad.setColorAt(0.301, base)
     grad.setColorAt(1, self.shadowColor)
     p.fillRect(rect, grad)
     
     light = QColor(255, 255, 255, 80)
     p.setPen(light)
     p.drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0))
     
     if self._usePixmapCache and not QPixmapCache.find(key, pixmap):
         painter.drawPixmap(clipRect.topLeft(), pixmap)
         p.end()
         del p
         QPixmapCache.insert(key, pixmap)
コード例 #4
0
 def horizontalGradient(self, painter, spanRect, clipRect):
     key = 'fancy vertical gradient %d %d %d %d %d'%(spanRect.width(), spanRect.height(), clipRect.width(),
                                          clipRect.height(), self.baseColor.rgb())
     pixmap = QPixmap()
     p = painter
     rect = QRect(clipRect)
     
     if self._usePixmapCache and not QPixmapCache.find(key, pixmap):
         pixmap = QPixmap(clipRect.size())
         p = QPainter(pixmap)
         rect = QRect(0, 0, clipRect.width(), clipRect.height())
     
     base = self.baseColor
     grad = QLinearGradient(QPointF(rect.topLeft()), QPointF(rect.bottomLeft()))
     grad.setColorAt(0, self.highlightColor.lighter(120))
     if rect.height() == self.navigationWidgetHeight:
         grad.setColorAt(0.4, self.highlightColor)
         grad.setColorAt(0.401, base)
     grad.setColorAt(1, self.shadowColor)
     p.fillRect(rect, grad)
     
     shadowGradient = QLinearGradient(QPointF(spanRect.topLeft()), QPointF(spanRect.topRight()))
     shadowGradient.setColorAt(0, QColor(0, 0, 0, 30))
     highlight = self.highlightColor.lighter(130)
     highlight.setAlpha(100)
     shadowGradient.setColorAt(0.7, highlight)
     shadowGradient.setColorAt(1, QColor(0, 0, 0, 40))
     p.fillRect(rect, shadowGradient)
 
     if self._usePixmapCache and not QPixmapCache.find(key, pixmap):
         painter.drawPixmap(clipRect.topLeft(), pixmap)
         p.end()
         del p
         QPixmapCache.insert(key, pixmap)
コード例 #5
0
def get_ammo(ammo_id, x, y):

    if ammo_id == -1:
        return None

    ammo_file = os.path.join(AMMO_DIR, "kotodama_ico_%03d.png" % ammo_id)
    ammo_border_file = os.path.join(AMMO_DIR, "border.png")

    if not os.path.isfile(ammo_file):
        ammo_file = os.path.join(AMMO_DIR, "kotodama_ico_%03d.png" % 999)

    ammo = QImage(ammo_file)
    border = QImage(ammo_border_file)

    x_pos = x
    y_pos = y

    border_x = x_pos - ((border.width() - ammo.width()) / 2)
    border_y = y_pos - ((border.height() - ammo.height()) / 2)

    out = QImage(IMG_W, IMG_H, QImage.Format_ARGB32_Premultiplied)
    out.fill(QColor(0, 0, 0, 0).rgba())
    painter = QPainter(out)

    painter.drawImage(QRect(x_pos, y_pos, ammo.width(), ammo.height()), ammo,
                      ammo.rect())
    painter.drawImage(
        QRect(border_x, border_y, border.width(), border.height()), border,
        border.rect())

    painter.end()

    return out
コード例 #6
0
def get_cutin(cutin_id):

    if cutin_id == -1:
        return None

    cutin_file = os.path.join(CUTIN_DIR, "cutin_ico_%03d.png" % cutin_id)
    cutin_border_file = os.path.join(CUTIN_DIR, "border.png")

    if not os.path.isfile(cutin_file):
        cutin_file = os.path.join(CUTIN_DIR, "cutin_ico_%03d.png" % 999)

    cutin = QImage(cutin_file)
    border = QImage(cutin_border_file)

    x_pos = 307
    y_pos = 91

    border_x = x_pos - ((border.width() - cutin.width()) / 2)
    border_y = y_pos - ((border.height() - cutin.height()) / 2)

    out = QImage(IMG_W, IMG_H, QImage.Format_ARGB32_Premultiplied)
    out.fill(QColor(0, 0, 0, 0).rgba())
    painter = QPainter(out)

    painter.drawImage(QRect(x_pos, y_pos, cutin.width(), cutin.height()),
                      cutin, cutin.rect())
    painter.drawImage(
        QRect(border_x, border_y, border.width(), border.height()), border,
        border.rect())

    painter.end()

    return out
コード例 #7
0
    def addTestImage(self, color_image):
        self.ocr_areas = OCRAreasFinder(color_image, self.settings["contrast"])
        self.market_width = self.ocr_areas.market_width
        self.valid_market = self.ocr_areas.valid
        if self.settings['gray_preview']:
            img = cv2.imread(
                unicode(self.hiddentext).encode(sys.getfilesystemencoding()),
                0)
            img = array2qimage(img)
            pix = QPixmap.fromImage(img)
        else:
            pix = QPixmap(self.hiddentext)
        width = pix.width()
        height = pix.height()
        if height > 0:
            aspect_ratio = float(width) / height
            if aspect_ratio > 1.78:
                new_w = int(1.77778 * height)
                rect = QRect((width - new_w) / 2, 0, new_w, height)
                pix = pix.copy(rect)

        if self.valid_market:
            points = self.ocr_areas.market_table
            self.market_offset = (points[0][0], points[0][1])
            station = self.ocr_areas.station_name
            self.station_offset = (station[0][0], station[0][1])
            rect = QRect(0, 0, points[1][0] + 20, points[1][1] + 20)
            cut = pix.copy(rect)
            return cut
        else:
            self.market_offset = (0, 0)
            self.station_offset = (0, 0)

        return pix
コード例 #8
0
 def showEvent(self, event):
     super(BaseDialog, self).showEvent(event)
     x, y = self.geometry().x(), self.geometry().y()
     self._animation.setStartValue(QRect(x, 0, self.width(), self.height()))
     self._animation.setEndValue(QRect(x, y, self.width(), self.height()))
     self._animation.start()
     self.line.setFocus()
コード例 #9
0
    def setupUi(self):
        self.resize(400, 400)
        self.setWindowTitle('Upload layer to Shogun')

        title = QtGui.QLabel(self)
        title.setGeometry(50, 30, 300, 70)
        title.setText(
            'Please select the layer you wish to upload to the \n Shogun Server'
        )

        self.layerBox = QgsMapLayerComboBox(self)
        self.layerBox.setGeometry(QRect(50, 100, 300, 30))

        self.uploadButton = QtGui.QPushButton(self)
        self.uploadButton.setGeometry(QRect(250, 160, 100, 35))
        self.uploadButton.setText('Upload Layer')

        self.cancelButton = QtGui.QPushButton(self)
        self.cancelButton.setGeometry(QRect(140, 160, 100, 35))
        self.cancelButton.setText('Cancel')
        self.cancelButton.clicked.connect(self.hide)

        self.logWindow = QtGui.QTextEdit(self)
        self.logWindow.setGeometry(QRect(50, 200, 300, 180))
        self.logWindow.setReadOnly(True)
        self.logWindow.setText('Upload Log:')
コード例 #10
0
    def __init__(self):
        QWidget.__init__(self)
        self.setWindowTitle("Crypto App")
        self.resize(500, 260)
        self.setMinimumSize(QSize(500, 260))
        self.setMaximumSize(QSize(500, 260))
        self.label = QLabel(self)
        self.label.setGeometry(QRect(66, 55, 150, 150))
        self.label.setPixmap(QPixmap("images/padlock.png"))
        self.label.setScaledContents(True)
        self.label.setToolTip('Encrypt files and folders')

        self.label_2 = QLabel(self)
        self.label_2.setGeometry(QRect(282, 55, 150, 150))
        self.label_2.setPixmap(QPixmap("images/unlock.png"))
        self.label_2.setScaledContents(True)
        self.label_2.setToolTip('Decrypt files and folders')
        self.label_2.mousePressEvent = self.__initDecrypter

        self.label_3 = QLabel(self)
        self.label_3.setGeometry(QRect(66, 180, 150, 16))
        self.label_3.setAlignment(Qt.AlignCenter)
        self.label_3.setText('<b style="color: white">ENCRYPT</b>')

        self.label_4 = QLabel(self)
        self.label_4.setGeometry(QRect(282, 180, 150, 16))
        self.label_4.setAlignment(Qt.AlignCenter)
        self.label_4.setText('<b style="color: white">DECRYPT</b>')

        self.label_3.mousePressEvent = self.label.mousePressEvent = self.__initEncrypter
        self.label_4.mousePressEvent = self.label_2.mousePressEvent = self.__initDecrypter
コード例 #11
0
 def pixelRect(self, i, j):
     if self.zoom >= 3:
         return QRect(self.zoom * i + 1, self.zoom * j + 1,
                      self.zoom - 1, self.zoom - 1)
     else:
         return QRect(self.zoom * i, self.zoom * j,
                      self.zoom, self.zoom)
コード例 #12
0
 def __window_stick_to(self, s_type):
     if self.__is_sticking:
         return
     if s_type == self.StickType.LEFT:
         geometry_tgt = QRect(
             -self.OFFSET_BORDER_LEFT, -self.OFFSET_BORDER_TOP,
             QApplication.desktop().screenGeometry().width() / 2 +
             self.OFFSET_BORDER_LEFT + self.OFFSET_BORDER_RIGHT,
             QApplication.desktop().availableGeometry().height() +
             self.OFFSET_BORDER_TOP + self.OFFSET_BORDER_BOTTOM)
         if self.geometry() != geometry_tgt:
             self.setGeometry(geometry_tgt)
             self.__is_sticking = True
             return
     if s_type == self.StickType.RIGHT:
         geometry_tgt = QRect(
             QApplication.desktop().screenGeometry().width() / 2 -
             self.OFFSET_BORDER_LEFT, -self.OFFSET_BORDER_TOP,
             QApplication.desktop().screenGeometry().width() / 2 +
             self.OFFSET_BORDER_LEFT + self.OFFSET_BORDER_RIGHT,
             QApplication.desktop().availableGeometry().height() +
             self.OFFSET_BORDER_TOP + self.OFFSET_BORDER_BOTTOM)
         if self.geometry() != geometry_tgt:
             self.setGeometry(geometry_tgt)
             self.__is_sticking = True
             return
     if s_type == self.StickType.FULL_SCREEN:
         self.setGeometry(
             -self.OFFSET_BORDER_LEFT, -self.OFFSET_BORDER_TOP,
             QApplication.desktop().availableGeometry().width() +
             self.OFFSET_BORDER_RIGHT + self.OFFSET_BORDER_LEFT,
             QApplication.desktop().availableGeometry().height() +
             self.OFFSET_BORDER_TOP + self.OFFSET_BORDER_BOTTOM)
         self.__is_sticking = True
         return
コード例 #13
0
def get_movie_icon(file_id):
  
  icon_file   = os.path.join(MOVIE_DIR, "movie_%03d.png" % file_id)
  border_file = os.path.join(MOVIE_DIR, "clip.png")
  
  if not os.path.isfile(icon_file):
    icon_file = os.path.join(MOVIE_DIR, "movie_%03d.png" % 999)
  
  icon   = QImage(icon_file)
  border = QImage(border_file)
  
  x_pos = 10
  y_pos = 45
  
  x_offset = 29
  y_offset = 88
  
  out = QImage(IMG_W, IMG_H, QImage.Format_ARGB32_Premultiplied)
  out.fill(QColor(0, 0, 0, 0).rgba())  
  painter = QPainter(out)
  
  painter.drawImage(QRect(x_pos, y_pos, border.width(), border.height()), border, border.rect())
  painter.drawImage(QRect(x_pos + x_offset, y_pos + y_offset, icon.width(), icon.height()), icon, icon.rect())
  
  painter.end()
  
  return out
コード例 #14
0
def _render_qwebpage_vector(web_page, logger,
                            in_viewport, out_viewport, image_size):
    """
    Render a webpage using vector rescale method.

    :param in_viewport: region of the webpage to render from
    :param out_viewport: region of the image to render to
    :param image_size: size of the resulting image

    :type in_viewport: QRect
    :type out_viewport: QRect
    :type image_size: QSize

    """
    web_rect = QRect(in_viewport)
    render_rect = QRect(out_viewport)
    canvas_size = QSize(image_size)

    logger.log("png render: rendering %s of the web page" % web_rect,
               min_level=2)
    logger.log("png render: rendering into %s of the canvas" % render_rect,
               min_level=2)
    logger.log("png render: canvas size=%s" % canvas_size, min_level=2)

    if _qpainter_needs_tiling(render_rect, canvas_size):
        logger.log("png render: draw region too large, rendering tile-by-tile",
                   min_level=2)
        return _render_qwebpage_tiled(web_page, logger,
                                      web_rect, render_rect, canvas_size)
    else:
        logger.log("png render: rendering webpage in one step", min_level=2)
        return _render_qwebpage_full(web_page, logger,
                                     web_rect, render_rect, canvas_size)
コード例 #15
0
    def paint(self, painter, objects, widget):
        ''' Required by QGraphicsItem '''
        painter.setFont(self.FONT_LEGEND)
        for y,x in product(range(self.height), range(self.width)):
            painter.setPen(self.PEN_GRID)
            if self.highlight == (x, y):
                painter.setBrush(self.COLOR_HIGHLIGHT)
            else:
                painter.setBrush(self.COLOR_ODD if (x + y) % 2 != 0 else
                                 self.COLOR_EVEN)
            painter.drawRect(self.LEGEND_SIZE + x * self.CELL_SIZE,
                             self.LEGEND_SIZE + y * self.CELL_SIZE,
                             self.CELL_SIZE, self.CELL_SIZE)

            if x == 0:
                painter.setPen(self.PEN_LEGEND)
                painter.drawText(QRect(0, self.LEGEND_SIZE + y *
                                       self.CELL_SIZE, self.LEGEND_SIZE - 4,
                                       self.CELL_SIZE),
                                 Qt.AlignCenter | Qt.AlignRight, str(y))
            if y == 0:
                painter.setPen(self.PEN_LEGEND)
                painter.drawText(QRect(self.LEGEND_SIZE + x * self.CELL_SIZE,
                                       0, self.CELL_SIZE, self.LEGEND_SIZE -2),
                                 Qt.AlignCenter | Qt.AlignBottom, str(x))
コード例 #16
0
    def set_thumbnail(self):
        """
        Sets thumbnail to the document widget by
        cropping if necessary.
        :return: None
        :rtype: NoneType
        """
        extension = self._displayName[self._displayName.rfind('.'):]

        QApplication.processEvents()
        doc_path = u'{}/{}/{}/{}/{}{}'.format(
            source_document_location(), unicode(self.curr_profile.name),
            unicode(self._source_entity),
            unicode(self.doc_type_value()).replace(' ', '_'),
            unicode(self.fileUUID), unicode(extension)).lower()

        ph_image = QImage(doc_path)
        ph_pixmap = QPixmap.fromImage(ph_image)
        # If width is larger than height, use height as width and height
        if ph_pixmap.width() > ph_pixmap.height():
            rectangle = QRect(0, 0, ph_pixmap.height(), ph_pixmap.height())
            ph_pixmap = ph_pixmap.copy(rectangle)
        # If height is larger than width, use width as width and height
        elif ph_pixmap.height() > ph_pixmap.width():
            rectangle = QRect(0, 0, ph_pixmap.width(), ph_pixmap.width())
            ph_pixmap = ph_pixmap.copy(rectangle)

        self.lblThumbnail.setPixmap(ph_pixmap)
        self.lblThumbnail.setScaledContents(True)
コード例 #17
0
    def  __init__(self):
        QDialog.__init__(self)
        self.resize(400, 300)
        self.setWindowTitle('Connection Dialog')

        self.label = QLabel(self)
        self.label.setGeometry(QRect(140, 150, 81, 20))
        self.label.setText('username')
        self.label2 = QLabel(self)
        self.label2.setGeometry(QRect(140, 190, 81, 20))
        self.label2.setText('password')
        self.label3 = QLabel(self)
        self.label3.setGeometry(QRect(40, 32, 151, 20))
        self.label3.setText('Name of the Shogun Client')
        self.label4 = QLabel(self)
        self.label4.setGeometry(QRect(40, 82, 151, 20))
        self.label4.setText('URL:')

        self.nameIn = QLineEdit(self)
        self.nameIn.setGeometry(QRect(200, 30, 180, 27))
        self.nameIn.setText('Default Shogun Client')
        self.urlIn = QLineEdit(self)
        self.urlIn.setGeometry(QRect(122, 80, 258, 27))
        self.urlIn.setPlaceholderText('i. e.: http(s)://.../shogun2-webapp')
        self.userIn = QLineEdit(self)
        self.userIn.setGeometry(QRect(230, 150, 150, 27))
        self.passwordIn = QLineEdit(self)
        self.passwordIn.setGeometry(QRect(230, 190, 150, 27))
        self.passwordIn.setEchoMode(QLineEdit.Password)
        self.okButton = QPushButton(self)
        self.okButton.setGeometry(QRect(270, 240, 85, 27))
        self.okButton.setText('OK')
        self.cancelButton = QPushButton(self)
        self.cancelButton.setGeometry(QRect(180, 240, 85, 27))
        self.cancelButton.setText('Cancel')
コード例 #18
0
ファイル: BoxTemperature.py プロジェクト: LEDS/Lifebox
    def settings(self, parent):
        # CRIANDO O GRUPOBOXTEMPS PARA POR OS LABELS E LCD'S
        self.groupBoxTemps = QGroupBox(parent)

        # CRIANDO O LABEL PARA INFORMAR O QUE O LCD ESTÁ MOSTRANDO
        self.lbTemp1 = QLabel(self.groupBoxTemps)
        self.lbTemp1.setGeometry(QRect(70, 10, 127, 10))
        self.lbTemp1.setMaximumSize(QSize(16777215, 10))
        self.lbTemp1.setText("Termometro 1")
        self.lbTemp1.setAlignment(Qt.AlignCenter)

        # CRIANDO O LABEL PARA INFORMAR O QUE O LCD ESTÁ MOSTRANDO
        self.lbTemp2 = QLabel(self.groupBoxTemps)
        self.lbTemp2.setGeometry(QRect(330, 10, 130, 10))
        self.lbTemp2.setMaximumSize(QSize(16777215, 10))
        self.lbTemp2.setText("Termometro 2")
        self.lbTemp2.setAlignment(Qt.AlignCenter)

        # CRIANDO O LCD PARA INFORMAR A TEMPERATURA DO TERMOMETRO 1
        self.lcdTemp1 = QLCDNumber(self.groupBoxTemps)
        self.lcdTemp1.setGeometry(QRect(30, 30, 211, 71))
        self.lcdTemp1.display("00.00")
        self.lcdTemp1.setDigitCount(6)

        # CRIANDO O LCD PARA INFORMAR A TEMPERATURA DO TERMOMETRO 2
        self.lcdTemp2 = QLCDNumber(self.groupBoxTemps)
        self.lcdTemp2.setGeometry(QRect(290, 30, 211, 71))
        self.lcdTemp2.display("00.00")
        self.lcdTemp2.setDigitCount(6)

        # COLOCANDO LAYOUT NO GRUPOBOXTEMPS
        self.addWidget(self.groupBoxTemps)
コード例 #19
0
 def resizeEvent(self, _event):
     q = self.parentWidget()
     fw = q.isFloating() and q.style().pixelMetric(
         QStyle.PM_DockWidgetFrameWidth, None, q) or 0
     opt = QStyleOptionDockWidgetV2()
     opt.initFrom(q)
     opt.rect = QRect(
         QPoint(fw, fw),
         QSize(self.geometry().width() - (fw * 2),
               self.geometry().height() - (fw * 2)))
     opt.title = q.windowTitle()
     opt.closable = self.hasFeature(q, QDockWidget.DockWidgetClosable)
     opt.floatable = self.hasFeature(q, QDockWidget.DockWidgetFloatable)
     floatRect = q.style().subElementRect(QStyle.SE_DockWidgetFloatButton,
                                          opt, q)
     if not floatRect.isNull():
         self.floatButton.setGeometry(floatRect)
     closeRect = q.style().subElementRect(QStyle.SE_DockWidgetCloseButton,
                                          opt, q)
     if not closeRect.isNull():
         self.closeButton.setGeometry(closeRect)
     top = fw
     if not floatRect.isNull():
         top = floatRect.y()
     elif not closeRect.isNull():
         top = closeRect.y()
     if self.checkStateButton:
         size = self.checkStateButton.size()
         if not closeRect.isNull():
             size = self.closeButton.size()
         elif not floatRect.isNull():
             size = self.floatButton.size()
         checkStateRect = QRect(QPoint(fw, top), size)
         self.checkStateButton.setGeometry(checkStateRect)
コード例 #20
0
    def preparePixmap(self):
        """ Prepare the pixmap(s) for the transition.

        This method draws the starting pixmap into the output pixmap.
        The transition update then draws over the output with the
        proper portion of the ending pixmap.

        """
        start = self.startPixmap()
        end = self.endPixmap()
        size = start.size().expandedTo(end.size())
        width = size.width()
        height = size.height()
        painter = QPainter(self.outPixmap())
        painter.drawPixmap(0, 0, start)
        direction = self.direction()
        if direction == self.LeftToRight:
            start_rect = QRect(0, 0, 0, height)
        elif direction == self.RightToLeft:
            start_rect = QRect(width, 0, 0, height)
        elif direction == self.TopToBottom:
            start_rect = QRect(0, 0, width, 0)
        elif direction == self.BottomToTop:
            start_rect = QRect(0, height, width, 0)
        else:
            raise ValueError('Invalid direction: %s' % direction)
        end_rect = QRect(0, 0, width, height)
        return start_rect, end_rect
コード例 #21
0
ファイル: messages.py プロジェクト: THECAESAR279/pyasteroids
    def __init__(self, message, str=None):
        cfg = Config('chats', message)

        if (str is None):
            self.str = cfg.get('message')
        else:
            self.str = str

        self.str = self.str.replace('\\\n', '').replace('\n', '\n\n')

        self.duration = cfg.get('duration')

        self.font = FontManager.getFont(cfg.get('font'))
        self.font.setPointSize(cfg.get('font_size'))
        self.font_color = QColor.fromRgb(*cfg.get('font_color'))

        self.image = QImage(cfg.get('image_path'))

        p = cfg.get('image_pos')
        self.image_rect = QRect(0., 0., self.image.width(),
                                self.image.height())
        self.image_rect.moveCenter(QPoint(p[0], p[1]))

        self.text_rect = QRect(*cfg.get('text_rect'))

        self.has_cursor = True
        self.blink_elapsed = 0.
        self.blink_time = cfg.get('blink_time')

        self.elapsed = 0.
        self.message_sz = len(self.str)
コード例 #22
0
    def rearangeDescriptionWidgets(self):
        self._activeSize = QSize(0.3 * self.width(), 0.1 * self.height())
        self._prototypingRect = QRect(
            QPoint(0.5 * (self.width() - self._activeSize.width()), 0),
            self._activeSize)
        self._executionRect = QRect(QPoint(0, 0.635 * self.height()),
                                    self._activeSize)
        self._verifyingRect = QRect(
            QPoint(self.width() - self._activeSize.width(),
                   0.635 * self.height()), self._activeSize)
        self._descriptionActiveRects[0] = self._prototypingRect
        self._descriptionActiveRects[1] = self._executionRect
        self._descriptionActiveRects[2] = self._verifyingRect

        self._prototypingDescriptionWidget.move(
            self.mapToParent(self._prototypingRect.topLeft()) +
            QPoint((self._prototypingRect.width() -
                    self._prototypingDescriptionWidget.width()) *
                   0.5, -self._prototypingDescriptionWidget.height()))
        self._executionDescriptionWidget.move(
            self.mapToParent(self._executionRect.topLeft()) - QPoint(
                self._executionDescriptionWidget.width(), -0.5 *
                (self._executionRect.height() -
                 self._executionDescriptionWidget.height())))
        self._verifyingDescriptionWidget.move(
            self.mapToParent(self._verifyingRect.topRight()) - QPoint(
                0, -0.5 * (self._verifyingRect.height() -
                           self._verifyingDescriptionWidget.height())))
コード例 #23
0
 def testArrowContact(self, indices, x, y):
     if type(indices) != list: indices = [indices]
     for index in indices:
         if index >= len(self.attributes) or index < 0:
             continue
         int_x = self.transform(xBottom, index)
         bottom = self.transform(
             yLeft,
             self.selection_conditions.get(self.attributes[index],
                                           [0, 1])[0])
         bottom_rect = QRect(int_x - self.bottom_pixmap.width() / 2, bottom,
                             self.bottom_pixmap.width(),
                             self.bottom_pixmap.height())
         if bottom_rect.contains(QPoint(x, y)):
             return 1, (index, 0)
         top = self.transform(
             yLeft,
             self.selection_conditions.get(self.attributes[index],
                                           [0, 1])[1])
         top_rect = QRect(int_x - self.top_pixmap.width() / 2,
                          top - self.top_pixmap.height(),
                          self.top_pixmap.width(), self.top_pixmap.height())
         if top_rect.contains(QPoint(x, y)):
             return 1, (index, 1)
     return 0, (0, 0)
コード例 #24
0
 def paintVerticalCell(self, painter: QPainter, hv: QHeaderView,
                       cellIndex: QModelIndex, leafIndex: QModelIndex,
                       logicalLeafIndex: int,
                       styleOptions: QStyleOptionHeader,
                       sectionRect: QRect, left: int):
     uniopt = QStyleOptionHeader(styleOptions)
     self.setForegroundBrush(uniopt, cellIndex)
     self.setBackgroundBrush(uniopt, cellIndex)
     width = self.cellSize(cellIndex, hv, uniopt).width()
     if cellIndex == leafIndex:
         width = sectionRect.width() - left
     top = self.currentCellLeft(cellIndex, leafIndex, logicalLeafIndex,
                                sectionRect.top(), hv)
     height = self.currentCellWidth(cellIndex, leafIndex,
                                    logicalLeafIndex, hv)
     r = QRect(left, top, width, height)
     uniopt.text = cellIndex.data(Qt.DisplayRole)
     painter.save()
     uniopt.rect = r
     if cellIndex.data(Qt.UserRole):
         hv.style().drawControl(QStyle.CE_HeaderSection, uniopt,
                                painter, hv)
         m = QMatrix()
         m.rotate(-90)
         painter.setWorldMatrix(m, True)
         new_r = QRect(0, 0, r.height(), r.width())
         new_r.moveCenter(QPoint(-r.center().y(), r.center().x()))
         uniopt.rect = new_r
         hv.style().drawControl(QStyle.CE_HeaderLabel, uniopt, painter,
                                hv)
     else:
         hv.style().drawControl(QStyle.CE_Header, uniopt, painter, hv)
     painter.restore()
     return left + width
コード例 #25
0
def decorate_welcome_icon(icon, background_color):
    """Return a `QIcon` with a circle shaped background.
    """
    welcome_icon = QIcon()
    sizes = [32, 48, 64, 80]
    background_color = NAMED_COLORS.get(background_color, background_color)
    background_color = QColor(background_color)
    grad = radial_gradient(background_color)
    for size in sizes:
        icon_pixmap = icon.pixmap(5 * size / 8, 5 * size / 8)
        icon_size = icon_pixmap.size()
        icon_rect = QRect(QPoint(0, 0), icon_size)

        pixmap = QPixmap(size, size)
        pixmap.fill(QColor(0, 0, 0, 0))
        p = QPainter(pixmap)
        p.setRenderHint(QPainter.Antialiasing, True)
        p.setBrush(QBrush(grad))
        p.setPen(Qt.NoPen)
        ellipse_rect = QRect(0, 0, size, size)
        p.drawEllipse(ellipse_rect)
        icon_rect.moveCenter(ellipse_rect.center())
        p.drawPixmap(icon_rect.topLeft(), icon_pixmap)
        p.end()

        welcome_icon.addPixmap(pixmap)

    return welcome_icon
コード例 #26
0
ファイル: menu_qt.py プロジェクト: ohmyheartbeat/CCA
    def __init_buy_date(cls):
        cls.grid_layout_widget_3.setGeometry(QRect(160, 110, 101, 41))
        cls.grid_layout_widget_3.setObjectName(_fromUtf8("gridLayoutWidget_3"))
        cls.grid_layout_3.setObjectName(_fromUtf8("gridLayout_3"))
        cls.buy_date_title.setFont(WindowCons.get_font(bold=True))
        cls.buy_date_title.setTextFormat(Qt.PlainText)
        cls.buy_date_title.setAlignment(Qt.AlignCenter)
        cls.buy_date_title.setObjectName(_fromUtf8("buy_date_title"))
        cls.grid_layout_3.addWidget(cls.buy_date_title, 0, 0, 1, 1)

        cls.grid_layout_widget_15.setGeometry(QRect(280, 110, 141, 41))
        cls.grid_layout_widget_15.setObjectName(
            _fromUtf8("gridLayoutWidget_15"))
        cls.grid_layout_15.setObjectName(_fromUtf8("gridLayout_15"))
        cls.buy_date_input.setEnabled(True)
        size_policy = WindowCons.get_size_policy(cls.buy_date_input)
        cls.buy_date_input.setSizePolicy(size_policy)
        cls.buy_date_input.setFont(
            WindowCons.get_font(family=WindowCons.YAHEI_LIGHT_FAMILY, size=12))
        cls.buy_date_input.setWrapping(False)
        cls.buy_date_input.setCalendarPopup(True)
        cls.buy_date_input.setFrame(False)
        cls.buy_date_input.setDate(
            QDate(datetime.datetime.date(datetime.datetime.now())))
        cls.buy_date_input.setObjectName(_fromUtf8("buy_date_input"))
        cls.grid_layout_15.addWidget(cls.buy_date_input, 0, 0, 1, 1)
コード例 #27
0
ファイル: menu_qt.py プロジェクト: ohmyheartbeat/CCA
 def init_button(cls):
     """初始化按钮"""
     # cls.grid_layout_widget_26.setGeometry(QRect(160, 390, 121, 50))
     # cls.grid_layout_widget_26.setObjectName(_fromUtf8("grid_layout_widget_26"))
     # cls.grid_layout_26.setObjectName(_fromUtf8("grid_layout_26"))
     # cls.query_button.setFont(WindowCons.get_font(bold=True))
     # cls.query_button.setFlat(False)
     # cls.query_button.setObjectName(_fromUtf8("query_button"))
     # cls.grid_layout_26.addWidget(cls.query_button, 0, 0, 1, 1)
     # cls.grid_layout_widget_27.setGeometry(QRect(300, 390, 121, 50))
     # cls.grid_layout_widget_27.setObjectName(_fromUtf8("grid_layout_widget_27"))
     # cls.grid_layout_27.setObjectName(_fromUtf8("grid_layout_27"))
     # cls.compute_button.setFont(WindowCons.get_font(bold=True))
     # cls.compute_button.setObjectName(_fromUtf8("compute_button"))
     # cls.grid_layout_27.addWidget(cls.compute_button, 0, 0, 1, 1)
     cls.grid_layout_widget_28.setGeometry(QRect(440, 390, 121, 50))
     cls.grid_layout_widget_28.setObjectName(
         _fromUtf8("grid_layout_widget_28"))
     cls.grid_layout_28.setObjectName(_fromUtf8("grid_layout_28"))
     cls.save_button.setFont(WindowCons.get_font(bold=True))
     cls.save_button.setObjectName(_fromUtf8("save_button"))
     cls.grid_layout_28.addWidget(cls.save_button, 0, 0, 1, 1)
     cls.grid_layout_widget_29.setGeometry(QRect(570, 390, 160, 73))
     cls.grid_layout_widget_29.setObjectName(
         _fromUtf8("grid_layout_widget_29"))
     cls.grid_layout_29.setObjectName(_fromUtf8("grid_layout_29"))
     cls.text_edit.setEnabled(False)
     cls.text_edit.setReadOnly(True)
     cls.text_edit.setFrameShape(False)
     cls.text_edit.setObjectName(_fromUtf8("textEdit"))
     cls.grid_layout_29.addWidget(cls.text_edit, 0, 0, 1, 1)
コード例 #28
0
def draw_anagram(anagram):
  
  BOX_LEFT      = 4
  BOX_TOP       = 22
  BOX_X_OFFSET  = 31
  BOX_Y_OFFSET  = 61
  
  TEXT_X_OFFSET = 13
  TEXT_Y_OFFSET = 9
  TEXT_CLT      = 8
  FONT          = CLT[TEXT_CLT]['font']
  
  MAX_LETTERS   = 15
  
  BOX = QImage(os.path.join(ANAGRAM_DIR, "box.png"))
  QUESTION = QImage(os.path.join(ANAGRAM_DIR, "question.png"))
  out = QImage(os.path.join(ANAGRAM_DIR, "bg.png"))
  
  text = anagram.solution.translated
  
  if len(text) == 0:
    return out
  
  if not out.format() is QImage.Format_ARGB32_Premultiplied:
    out = out.convertToFormat(QImage.Format_ARGB32_Premultiplied)
  
  painter = QPainter(out)
  painter.setRenderHint(QPainter.Antialiasing, True)
  
  # Put them in a list so it's easier to loop.
  visible = [range(1, len(text) + 1), anagram.easy, anagram.normal, anagram.hard]
  
  x = BOX_LEFT
  y = BOX_TOP
  
  for row in range(len(visible)):
    
    if not visible[row] == None:
      for i, char in enumerate(text):
      
        if (i + 1) in visible[row]:
          
          painter.drawImage(QRect(x, y, BOX.width(), BOX.height()), BOX, BOX.rect())
          
          # Get info on our current letter.
          letter, (xshift, yshift, final_w, final_h) = get_letter(TEXT_CLT, char)
          painter.drawImage(QRect(x + TEXT_X_OFFSET + xshift, y + TEXT_Y_OFFSET + yshift, final_w, final_h), letter, letter.rect())
        
        else:
          painter.drawImage(QRect(x, y, QUESTION.width(), QUESTION.height()), QUESTION, QUESTION.rect())
        
        x += BOX_X_OFFSET
      
    x = BOX_LEFT
    y += BOX_Y_OFFSET
  
  painter.end()
  
  return out
コード例 #29
0
 def _subControlRect(self, subcontrol):
     if subcontrol == QStyle.SC_SliderGroove:
         return self.rect()
     if subcontrol == QStyle.SC_SliderHandle:
         if self.orientation() == Qt.Horizontal:
             return QRect(-self._HANDLE_WIDTH / 2, 0, self._HANDLE_WIDTH, self.rect().height())
         else:
             return QRect(0, -self._HANDLE_WIDTH / 2, self.rect().width(), self._HANDLE_WIDTH)
コード例 #30
0
ファイル: owdistancemap.py プロジェクト: neo-nie/orange3
    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton and self.__dragging:
            r1, c1 = self._cellAt(event.buttonDownPos(Qt.LeftButton))
            r2, c2 = self._cellCloseTo(event.pos())
            selrange = QRect(c1, r1, 1, 1).united(QRect(c2, r2, 1, 1))
            self.__elastic_band_select(selrange, self.Select)

        super().mouseMoveEvent(event)
        event.accept()