예제 #1
0
    def text_changed(self, t):
        fm = QFontMetrics(self.font())
        text_width = fm.width(t)
        text_width = text_width+25
        self.setFixedWidth(text_width if text_width > self.base_width else self.base_width)

        self.parent_node_instance.update_shape()
예제 #2
0
def strRect(s, fontMetrics: QtGui.QFontMetrics):
    #baseWidth = fontMetrics.boundingRect(s).width()
    baseWidth = fontMetrics.horizontalAdvance(s)
    sWidth = baseWidth  # - fontMetrics.leftBearing(s[0])
    #sWidth -= fontMetrics.rightBearing(s[-1])
    r = QtCore.QRect(0, 0, sWidth, fontMetrics.height())
    return r
예제 #3
0
    def __init__(self, scene: QGraphicsScene, zoomable: bool = True):
        super().__init__()

        self.setScene(scene)

        self._zoomable = zoomable
        if self._zoomable:
            self.enable_zooming()

        self._cur_scale = self._calculate_scale()

        self._scale_font = QFont()
        self._scale_font.setPointSize(16)
        self._scale_font.setBold(True)
        self._scale_font_metrics = QFontMetrics(self._scale_font)
        self._scale_text_rect = QRect()

        self._viewport_anchors = None
        self._reset_viewport_anchors()
        self._viewport_anchoring = False

        self._viewport_anchoring_scheduled = False
        scene.sceneRectChanged.connect(self._reset_viewport_anchors)

        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
예제 #4
0
 def sizeHint(self, option: QStyleOptionViewItem,
              index: QModelIndex) -> QSize:
     metrics = QFontMetrics(self.get_font(option))
     left = metrics.size(0, self.left_text(index))
     right = metrics.size(0, self.right_text(index))
     return QSize(max(left.width(), right.width()) + 2 * self.HMARGIN,
                  left.height() + right.height() + 2 * self.VMARGIN)
예제 #5
0
def text_size(text, font: QFont) -> 'SizeF':
    font_metrics = QFontMetrics(font)

    lines = text.split('\n')
    width = max(map(font_metrics.width, lines))
    height = font_metrics.height() * len(lines)
    return SizeF(width, height)
예제 #6
0
 def __init__(self, item, parent):
     super(CollapsibleArrowAndTitle, self).__init__(item, parent=parent)
     self.isCollapsed = False
     fontMetric = QFontMetrics(self.item().data(Qt.FontRole))
     text = self.item().data(renderSetupRoles.NODE_TYPE_STR)
     self.setMinimumSize(self.WIDTH + fontMetric.width(text), self.HEIGHT)
     self.arrowPoints = BaseDelegate.EXPANDED_ARROW
예제 #7
0
 def getTextWidth(self, text: str) -> int:
     font = self.font()
     # ps = font.pixelSize()  # --> -1
     font.setPixelSize(0)
     fm = QFontMetrics(font)
     width = fm.width(text)
     return width
예제 #8
0
    def sizeHint(self, option: QStyleOptionViewItem, index: QModelIndex) -> QSize:
        metrics = QFontMetrics(self.get_font(option))
        widths = []
        heights = []

        icon_size = self.icon_size(option)
        icon_width = 0
        icon_height = 0
        if icon_size.width():
            icon_width = icon_size.width() + self.HMARGIN
        if icon_size.height():
            icon_height = icon_size.height() + self.VMARGIN

        for row in range(self.rows):
            width = 0
            height = 0
            for column in range(self.columns):
                size = metrics.size(0, self.text_for(index, row, column))
                width += size.width()
                height = max(height, size.height())
            widths.append(width)
            heights.append(height)

        return QSize(
            icon_width + max(widths) + 2 * self.HMARGIN,
            max(icon_height, sum(heights)) + 2 * self.VMARGIN,
        )
예제 #9
0
    def showFolder(self, path):
        "displays current path, truncating as needed"
        if not path: return

        ell, sl = '\u2026', os.path.sep  # ellipsis, slash chars
        lfg, rfg = Qt.ElideLeft, Qt.ElideRight
        lst, wdh = os.path.basename(path), self.folderLabel.width()

        path = path.replace(os.path.altsep or '\\', sl)
        self.folderLabel.setToolTip(path)

        # truncate folder location
        fnt = QFontMetrics(self.folderLabel.font())
        txt = str(fnt.elidedText(path, lfg, wdh))

        if len(txt) <= 1:  # label is way too short
            self.folderLabel.setText('\u22ee' if txt != sl else txt)
            return  # but when would this happen?

        # truncate some more (don't show part of a folder name)
        if len(txt) < len(path) and txt[1] != sl:
            txt = ell + sl + txt.split(sl, 1)[-1]

            # don't truncate remaining folder name from the left
            if txt[2:] != lst and len(txt[2:]) < len(lst) + 2:
                txt = str(fnt.elidedText(ell + sl + lst, rfg, wdh))
        # you'd think len(txt) < len(lst) would work, but no; you'd be wrong

        self.folderLabel.setText(txt)
예제 #10
0
class ApolloGroupHeading(QWidget):
    def __init__(self, parent, text, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)

        self.text = text
        self.font_metrics = QFontMetrics(self.font())
        self.text_width = self.font_metrics.width(self.text)
        self.text_height = self.font_metrics.height()

    def sizeHint(self):
        return QSize(self.text_width, self.text_height)

    def paintEvent(self, event):
        p = QPainter(self)

        left_edge = self.width() // 2 - self.text_width // 2
        right_edge = self.width() // 2 + self.text_width // 2

        p.drawText(left_edge, self.text_height, self.text)

        x0 = 0
        x1 = left_edge - 4
        x2 = right_edge + 4
        x3 = self.width() - 1
        y0 = self.height() // 2 + 2
        y1 = self.height()

        p.drawLine(x0, y0, x1, y0)
        p.drawLine(x2, y0, x3, y0)
        p.drawLine(x0, y0, x0, y1)
        p.drawLine(x3, y0, x3, y1)

        p.end()
예제 #11
0
 def setModelData(self, editor: '_IntervalWidget',
                  model: QAbstractItemModel, index: QModelIndex) -> None:
     datetimes: List[QDateTime]
     datetimes, byDate, byTime = editor.getOptions()
     # Do some validation
     errors = list()
     if len(datetimes) < 2:
         errors.append(('e1', 'Error: at least one range must be defined'))
     if any([a >= b for a, b in zip(datetimes, datetimes[1:])]):
         errors.append(
             ('e2', 'Error: datetime points must be strictly increasing'))
     if errors:
         editor.handleErrors(errors)
         # Avoid setting options and leave editor open
         return
     options = ([
         pd.Timestamp(date.toPython(), tz='UTC') for date in datetimes
     ], byDate, byTime)
     model.setData(index, options, Qt.EditRole)
     # Resize rows. This assumes that the TableView is the delegate parent
     f = QFontMetrics(QFont())
     rowHeight = f.height() * len(options[0])
     table: QTableView = self.parent()
     table.setRowHeight(index.row(), rowHeight)
     # Close editor. Works because it's the delegate that tells the view to close it with this signal
     self.closeEditor.emit(self.w, QStyledItemDelegate.NoHint)
예제 #12
0
    def __init__(self, db_mngr, *db_urls):
        """Initializes form.

        Args:
            db_mngr (SpineDBManager): The manager to use
            *db_urls (tuple): Database url, codename.
        """
        super().__init__(flags=Qt.Window)
        from ..ui.data_store_view import Ui_MainWindow

        self.db_urls = list(db_urls)
        self.db_url = self.db_urls[0]
        self.db_mngr = db_mngr
        self.db_maps = [
            self.db_mngr.get_db_map_for_listener(self, url, codename=codename)
            for url, codename in self.db_urls
        ]
        self.db_map = self.db_maps[0]
        # Setup UI from Qt Designer file
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.takeCentralWidget()
        self.setWindowIcon(QIcon(":/symbols/app.ico"))
        self.setStyleSheet(MAINWINDOW_SS)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.qsettings = QSettings("SpineProject", "Spine Toolbox")
        self.err_msg = QErrorMessage(self)
        self.notification_stack = NotificationStack(self)
        self.err_msg.setWindowTitle("Error")
        self.parameter_tag_toolbar = ParameterTagToolBar(
            self, self.db_mngr, *self.db_maps)
        self.addToolBar(Qt.TopToolBarArea, self.parameter_tag_toolbar)
        self.selected_ent_cls_ids = {
            "object class": {},
            "relationship class": {}
        }
        self.selected_ent_ids = {"object": {}, "relationship": {}}
        self.selected_parameter_tag_ids = dict()
        self.selected_param_def_ids = {
            "object class": {},
            "relationship class": {}
        }
        self.parameter_value_list_model = ParameterValueListModel(
            self, self.db_mngr, *self.db_maps)
        fm = QFontMetrics(QFont("", 0))
        self.default_row_height = 1.2 * fm.lineSpacing()
        max_screen_height = max(
            [s.availableSize().height() for s in QGuiApplication.screens()])
        self.visible_rows = int(max_screen_height / self.default_row_height)
        self._selection_source = None
        self._selection_locked = False
        self._focusable_childs = [self.ui.treeView_parameter_value_list]
        self.settings_group = 'treeViewWidget'
        self.undo_action = None
        self.redo_action = None
        db_names = ", ".join(
            ["{0}[*]".format(db_map.codename) for db_map in self.db_maps])
        self.setWindowTitle("{0} - Data store view ".format(db_names))
        self.update_commit_enabled()
예제 #13
0
 def setText(self, text):
     self._text = text
     metrics = QFontMetrics(self._font)
     self._textRect = QRectF(metrics.boundingRect(
         QRect(0.0, 0.0, 150.0, 150.0),Qt.AlignLeft, self._text))
     self._textRect.translate(5, 5)
     self.prepareGeometryChange()
     self._rect = self._textRect.adjusted(-5, -5, 5, 5)
예제 #14
0
 def setText(self, text):
     self._text = text
     metrics = QFontMetrics(self._font)
     self._textRect = QRectF(metrics.boundingRect(
         QRect(0.0, 0.0, 150.0, 150.0),Qt.AlignLeft, self._text))
     self._textRect.translate(5, 5)
     self.prepareGeometryChange()
     self._rect = self._textRect.adjusted(-5, -5, 5, 5)
예제 #15
0
    def __init__(self, parent, text, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)

        self.text = text
        self.font_metrics = QFontMetrics(self.font())
        self.text_width = self.font_metrics.width(self.text)
        self.text_height = self.font_metrics.height()
예제 #16
0
    def _set_filename_text(self, text: str):
        self._lineedit_filename.setText(text)

        font = self._lineedit_filename.font()
        fontMetrics = QFontMetrics(font)
        textSize = fontMetrics.size(0, text)
        textHeight = textSize.height() + 26  # Need to tweak
        self._lineedit_filename.setMaximumHeight(textHeight)
예제 #17
0
    def setFont(self, qFont):
        qFont.setStyleHint(QFont.Monospace)
        qFont.setFixedPitch(True)
        fontMetrics = QFontMetrics(qFont)
        self.setTabStopWidth(self.__tabStop * fontMetrics.width(' '))
        self.__lineHeight = fontMetrics.height() * self.__lineHeightMultiplier

        super().setFont(qFont)
        self.__setLineHeight()
 def _create_raw_widget(self, ) -> QWidget:
     widget = QPlainTextEdit(self)
     font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
     font.setFixedPitch(True)
     metrics = QFontMetrics(font)
     widget.setFont(font)
     widget.setTabStopDistance(2 * metrics.width(' '))
     as_signal_instance(widget.textChanged).connect(self._on_raw_changed, )
     return widget
예제 #19
0
 def sizeHint(self, option: QStyleOptionViewItem,
              index: QModelIndex) -> QSize:
     left = self.icon_size(option).width() + self.HMARGIN
     metrics = QFontMetrics(self.get_font(option))
     first = metrics.size(0, self.first_row_text(index))
     second = metrics.size(0, self.second_row_text(index))
     text_width = max(first.width(), second.width())
     return QSize(left + text_width + 2 * self.HMARGIN,
                  first.height() + second.height() + 2 * self.VMARGIN)
예제 #20
0
    def text_changed(self, new_text):
        if self.resizing:
            fm = QFontMetrics(self.font())
            text_width = fm.width(new_text)
            new_width = text_width + 15
            self.setFixedWidth(
                new_width if new_width > self.base_width else self.base_width)

            self.parent_node_instance.update_shape()
예제 #21
0
    def drawHeader(self):
        """Draw logo/copyright in the header"""
        pHeight = 90
        pMargin = 15
        icon_path = cm.DIR_ICONS + "app.png"

        self.header_lbl.setMinimumHeight(pHeight)
        self.header_lbl.setFrameShape(QFrame.StyledPanel)
        self.header_lbl.setContentsMargins(0, 0, 0, 0)

        pixmap = QPixmap(450, pHeight)
        pixmap.fill(Qt.transparent)

        iconY = (pHeight - 64) / 2
        logoRect = QRect(pMargin, iconY, 64, 64)

        painter = QPainter(pixmap)
        painter.setBrush(QBrush(Qt.red))
        painter.drawPixmap(
            logoRect,
            QPixmap(icon_path).scaled(
                logoRect.width(),
                logoRect.height(),
                Qt.KeepAspectRatio,
                Qt.SmoothTransformation,
            ),
        )

        titleRect = QRect(logoRect.right() + 10, iconY, 200, pHeight)

        font = QFont()
        font.setBold(True)
        font.setPixelSize(16)
        painter.setFont(font)
        painter.setPen(QPen(QApplication.instance().palette().text().color()))
        painter.drawText(titleRect, Qt.AlignTop, "Cutevariant")

        font_metrics = QFontMetrics(font)
        font.setBold(False)
        font.setPixelSize(12)
        painter.setFont(font)
        painter.setPen(QPen(Qt.darkGray))
        titleRect.setY(titleRect.y() + font_metrics.height())

        painter.drawText(
            titleRect,
            Qt.AlignTop,
            f"Version %s\nGPL3 Copyright (C) 2018-2020\nLabsquare.org" % __version__,
        )

        self.header_lbl.setPixmap(pixmap)

        # Painting is finished !
        # Avoid Segfault:
        # QPaintDevice: Cannot destroy paint device that is being painted
        painter.end()
예제 #22
0
 def __init__(self, text, position, attachment_point, *args, **kwargs):
     super(TextItem, self).__init__(*args, **kwargs)
     self.text = text
     self.angle = kwargs.pop('angle')
     self.position = position
     self.font = QFont('Arial', 5)
     metrics = QFontMetrics(self.font)
     self.w = metrics.width(self.text)
     self.h = metrics.height()
     self.attachment_point = attachment_point
예제 #23
0
    def text_changed(self):
        t = self.toPlainText()
        fm = QFontMetrics(self.font())
        text_width = fm.width(self.get_longest_line(t))
        text_width = text_width+25
        text_height = fm.height()*(t.count('\n')+1)+12
        self.setFixedWidth(text_width if text_width > self.base_width else self.base_width)
        self.setFixedHeight(text_height if text_height > self.base_height else self.base_height)

        self.parent_node_instance.update_shape()
    def updateText(self):
        count_tracks = 0
        count_languages = 0
        tracks = []
        languages = []
        tracks_text = []
        languages_text = []
        text = ""
        for i in range(self.model().rowCount()):
            if self.model().item(i).checkState() == Qt.Checked:
                if self.model().item(i).text().find("Track") != -1:
                    count_tracks += 1
                    tracks.append(self.model().item(i).text())
                    tracks_text.append(
                        self.model().item(i).text().split(" ")[1])

                elif self.model().item(i).text() in AllSubtitlesLanguages:
                    count_languages += 1
                    languages.append(self.model().item(i).text())
                    languages_text.append(self.model().item(i).text())
        self.tracks = tracks_text
        self.languages = languages_text
        if count_tracks > 0:
            tracks_text = "Tracks: [" + ", ".join(tracks_text) + "]"
            text = tracks_text
        if count_languages > 0:
            languages_text = "Languages: [" + ", ".join(languages_text) + "]"
            if text != "":
                text = text + "," + languages_text
            else:
                text = languages_text

        # Compute elided text (with "...")
        metrics = QFontMetrics(self.lineEdit().font())
        elided_text = metrics.elidedText(text, Qt.ElideRight,
                                         self.lineEdit().width())
        if elided_text != "":
            non_italic_font = self.lineEdit().font()
            non_italic_font.setItalic(False)
            self.lineEdit().setFont(non_italic_font)
            self.lineEdit().setText(elided_text)
            if count_tracks > 0:
                self.hint = tracks_text
                if count_languages > 0:
                    self.hint = self.hint + "<br>" + languages_text
            elif count_languages > 0:
                self.hint = languages_text
        else:
            italic_font = self.lineEdit().font()
            italic_font.setItalic(True)
            self.lineEdit().setFont(italic_font)
            self.lineEdit().setText(self.empty_selection_string)
            self.hint = self.empty_selection_hint_string
        self.setToolTip(self.hint)
예제 #25
0
 def updateEditorGeometry(self, editor, option, index):
     super().updateEditorGeometry(editor, option, index)
     item = index.model().item_from_index(index)
     if item.item_type == "scenario active":
         size = option.rect.size()
         fm = QFontMetrics(index.data(Qt.FontRole))
         dx = fm.horizontalAdvance("active:")
         size.setWidth(size.width() - dx)
         editor.set_base_size(size)
         editor.set_base_offset(QPoint(dx, 0))
         editor.update_geometry()
예제 #26
0
    def paint(self, painter, option, widget):
        rect = self.boundingRect()
        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(self.backColor)
        painter.setBrush(brush)
        painter.drawRect(QRectF(0, 0, self.width, self.height))

        painter.setPen(QPen(Qt.red, 2))
        # painter.drawLine(QPointF(self.width/2, 0), QPointF(self.width/2, self.height))

        painter.drawLine(QPointF(0, self.height / 2),
                         QPointF(self.width, self.height / 2))

        font = painter.font()
        font.setPixelSize(12)
        font.setWeight(QFont.Bold)
        fontMetrics = QFontMetrics(font)
        painter.setFont(font)
        textRect = fontMetrics.boundingRect(str(self.currTime))
        painter.drawText(QPointF(50 + 5, self.height / 2), str(self.currTime))
        painter.setPen(self.linePen)

        # one line after 5 pixels
        startValue = self.currTime
        # origin = (self.width / 2) - (startValue * self.lineSpacing)
        # min = int(startValue - (self.width * .5) / self.lineSpacing)
        # max = int(startValue + (self.width * .5) / self.lineSpacing)

        origin = (self.height / 2) - (startValue * self.lineSpacing)
        min = int(startValue - (self.height * .5) / self.lineSpacing)
        max = int(startValue + (self.height * .5) / self.lineSpacing)

        for i in range(min, max):
            # x1 = x2 = origin + (i * self.lineSpacing)
            # y1 = self.height

            x1 = 0
            y1 = y2 = origin + (i * self.lineSpacing)

            if i % 10 == 0:
                x2 = 40
                if i >= 0:
                    font.setWeight(QFont.Bold)
                    font.setPixelSize(10)
                    painter.setFont(font)
                    painter.drawText(self.width - 20, y1, f'{i}')
            elif i % 5 == 0:
                x2 = 25
            else:
                x2 = 13
            if i >= 0:
                painter.drawLine(x1, y1, x2, y2)
                print(x2, y2)
    def add_item(self, item_str: str):
        """
        向导航栏中添加项目(代表一个选项卡),添加之前会查重
        :param item_str:项目名称(显示出来的文字)
        :return:None
        """
        if not item_str:
            return

        for key, value in self._m_item_maps.items():
            if value[0] == item_str:
                return  # 如果存在同名item,则返回

        f = QFont()
        f.setPointSize(self._m_item_font_size)
        fm = QFontMetrics(f)

        text_width = fm.width(item_str)
        text_height = fm.height()
        item_count = len(self._m_item_maps)
        if item_count > 0:
            if self._m_orientation == Qt.Horizontal:
                top_left = QPointF(self._m_total_text_width, 0)
                self._m_total_text_width += text_width + self._m_space
                bottom_right = QPointF(self._m_total_text_width, self._m_total_text_height)
            else:
                top_left = QPointF(0, self._m_total_text_height)
                self._m_total_text_height += text_height + self._m_space
                bottom_right = QPointF(self._m_total_text_width, self._m_total_text_height)

            self._m_item_maps[item_count] = [item_str, QRectF(top_left, bottom_right)]
        else:
            if self._m_orientation == Qt.Horizontal:
                # 水平方向,水平各占1个space, 竖直占1个space
                self._m_total_text_width = text_width + self._m_space
                self._m_total_text_height = text_height + self._m_space
            else:
                # 竖直方向, 水平各占2个space, 竖直占一个space
                self._m_total_text_width = text_width + 2 * self._m_space
                self._m_total_text_height = text_height + self._m_space

            top_left = QPointF(0.0, 0.0)
            bottom_right = QPointF(self._m_total_text_width, self._m_total_text_height)
            self._m_item_maps[item_count] = [item_str, QRectF(top_left, bottom_right)]
        self.setMinimumSize(self._m_total_text_width, self._m_total_text_height)

        if self._m_fixed:
            if self._m_orientation == Qt.Horizontal:
                self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)  # 固定高度
            else:
                self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred)  # 固定宽度
        if len(self._m_item_maps):
            self._m_start_rect = QRectF(self._m_item_maps[0][1])
        self.update()
예제 #28
0
 def check_if_name_need_resize_column_to_fit_content(self):
     new_column_width = 0
     for i in range(self.rowCount()):
         column_font = self.cellWidget(i, self.column_ids["Name"]).font()
         column_font_metrics = QFontMetrics(column_font)
         new_column_width = max(
             new_column_width,
             column_font_metrics.horizontalAdvance(
                 self.data[i].video_name_with_spaces))
     if new_column_width > self.columnWidth(self.column_ids["Name"]):
         self.resize_name_column_to_fit_content()
예제 #29
0
    def updateText(self):
        texts = []
        for i in range(self.model().rowCount()):
            if self.model().item(i).checkState() == Qt.Checked:
                texts.append(self.model().item(i).text())
        text = ", ".join(texts)

        # Compute elided text (with "...")
        metrics = QFontMetrics(self.lineEdit().font())
        elidedText = metrics.elidedText(text, Qt.ElideRight, self.lineEdit().width())
        self.lineEdit().setText(elidedText)
예제 #30
0
파일: ui.py 프로젝트: ramesharun/caribou
    def __init__(self, parameter):
        super().__init__()
        metrics = QFontMetrics(TEXT_FONT)
        self.min_height = metrics.height()
        self.setFont(TEXT_FONT)

        self.default_text = parameter.default
        self.textChanged.connect(self.on_update)

        self.highlighter = JSONHighlighter(self.document())
        self.setText(parameter.default)
예제 #31
0
 def resize_column(self, column_index):
     if column_index == self.column_ids["Name"]:
         for i in range(self.rowCount()):
             metrics = QFontMetrics(
                 self.cellWidget(i, self.column_ids["Name"]).font())
             elided_text = metrics.elidedText(
                 self.data[i].video_name_with_spaces, Qt.ElideRight,
                 self.columnWidth(self.column_ids["Name"]))
             self.data[i].video_name_displayed = chr(0x200E) + elided_text
             self.cellWidget(i, self.column_ids["Name"]).setText(
                 self.data[i].video_name_displayed)
     self.update()
예제 #32
0
 def createDropTextPixmap(self):
     pixmap = QPixmap(481, 300)
     pixmap.fill(QColor("#333333"))
     painter = QPainter(pixmap)
     font = QFont("Arial")
     font.setPixelSize(28)
     font.setBold(True)
     fm = QFontMetrics(font)
     painter.setFont(font)
     painter.setPen(QPen(QColor("#888888"), 1))
     text = "Drop the tileset image here"
     x = (pixmap.width()-fm.width(text))/2
     y = (pixmap.height()+fm.height())/2
     painter.drawText(x, y, text)
     del painter
     return pixmap