Esempio n. 1
0
    def new_tab(self, title, text):
        new_editor = QPlainTextEdit()
        new_editor.setFont(self._font)
        new_editor.setPlainText(text)
        TemplateHighlighter(new_editor.document())

        new_editor.textChanged.connect(self._text_changed)
        self._widgets_indexes[new_editor] = self.count()
        self.addTab(new_editor, title)
Esempio n. 2
0
class ToolsetHelpWidget(base.BaseFrame, object):
    def __init__(self, parent=None):
        super(ToolsetHelpWidget, self).__init__(parent=parent)

    def ui(self):
        super(ToolsetHelpWidget, self).ui()

        self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)

        self._image_label = label.BaseLabel(parent=self)
        self._title_label = label.BaseLabel(parent=self).strong()
        self._description_text = QPlainTextEdit(parent=self)
        # self._description_text.setFrameShape(QFrame.NoFrame)
        self._description_text.setMinimumWidth(200)
        self._description_text.setSizePolicy(QSizePolicy.Expanding,
                                             QSizePolicy.Expanding)
        self._gif_label = gif.GifLabel(parent=self)
        self._gif_label.set_size(256, 256)

        self.main_layout.addWidget(self._title_label)
        self.main_layout.addWidget(dividers.Divider())
        body_layout = layouts.HorizontalLayout(spacing=0, margins=(0, 0, 0, 0))
        body_layout.addWidget(self._description_text)
        body_layout.addWidget(self._gif_label)
        body_layout.addWidget(self._image_label)
        body_layout.addStretch()
        self.main_layout.addLayout(body_layout)

    def set_title(self, title):
        self._title_label.setText(str(title))

    def set_description(self, description):
        self._description_text.setPlainText(str(description))

    def set_image(self, image_file):
        if not image_file or not os.path.isfile(image_file):
            return
        self._image_label.setPixmap(
            QPixmap(image_file).scaled(QSize(256, 256), Qt.KeepAspectRatio))
        self._image_label.setVisible(True)
        self._gif_label.setVisible(False)

    def set_gif(self, gif_file):
        if not gif_file or not os.path.isfile(gif_file):
            return
        self._gif_label.set_file(gif_file)
        self._gif_label.setVisible(True)
        self._image_label.setVisible(False)
Esempio n. 3
0
class _ReportingWindow(QDialog):
    def __init__(self, name, report, parent=None):
        QDialog.__init__(self, parent)
        icon = self.style().standardIcon(QStyle.SP_MessageBoxCritical)

        self.setWindowTitle('Error reporting')
        self.setWindowIcon(icon)

        try:
            font = QFontDatabase().systemFont(QFontDatabase.FixedFont)
        except AttributeError as e:
            font = QFont()
            font.setStyleHint(QFont.TypeWriter)

        self.text = QPlainTextEdit()
        self.text.setFont(font)
        self.text.setReadOnly(True)
        self.text.setLineWrapMode(QPlainTextEdit.NoWrap)
        self.text.setPlainText(report)
        TracebackHighlighter(self.text.document())

        icon_label = QLabel()
        icon_label.setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE))

        label = QLabel("{} error !".format(name))
        label.setFont(QFont('default', pointSize=14))

        button_copy = QPushButton('Copy to clipboard')
        button_copy.clicked.connect(self._copy)

        layout = QGridLayout(self)
        layout.addWidget(icon_label, 0, 0)
        layout.addWidget(label, 0, 1)
        layout.addWidget(self.text, 1, 0, 1, 2)
        layout.addWidget(button_copy, 2, 0, 1, 2)
        layout.setColumnStretch(1, 100)

        self.setModal(True)
        self.resize(600, 400)

    def _copy(self):
        clipboard = QApplication.clipboard()
        clipboard.setText('```\n' + self.text.toPlainText() + '\n```')