Esempio n. 1
0
 def setValue(self, value):
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
         return
     self.setCurrentIndex(self.__values.index(value))
Esempio n. 2
0
    def __init__(self,
                 widget,
                 width=450,
                 height=50,
                 icon_size=40,
                 parent=None,
                 show_on_initialize=False,
                 stylesheet='',
                 popup_release=Qt.Key_Control,
                 show_at_cursor=True):

        self._tooltip_icon = None
        self._widget = widget
        self._icon_color = self.ETT_ICON_COLOR
        self._theme_color = self.ETT_THEME_COLOR
        self._link_color = self.ETT_LINK_COLOR
        self._popup_key = popup_release
        self._icon_size = icon_size
        self._font = QFont('sans')
        self._title_font = QFont('sans')

        super(ExpandedTooltipPopup,
              self).__init__(width=width,
                             height=height,
                             show_on_initialize=show_on_initialize,
                             parent=parent)

        if stylesheet != '':
            self.setStyleSheet(stylesheet)

        if show_at_cursor:
            self.move(QCursor.pos())

        self.setStyle(self.style())
Esempio n. 3
0
 def setValue(self, value):
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
         return
     self.setCurrentIndex(self.__values.index(value))
Esempio n. 4
0
 def setValue(self, value):
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
         return
     elif isinstance(value, Q_):
         super().display(value.to(self._units).magnitude)
     else:
         super().display(value)
Esempio n. 5
0
 def setValue(self, value):
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
         return
     elif isinstance(value, Q_):
         super().display(value.to(self._units).magnitude)
     else:
         super().display(value)
Esempio n. 6
0
 def setValue(self, value):
     """Set widget value scaled by units.
     """
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
     elif isinstance(value, Q_):
         super().setValue(value.to(self._units).magnitude)
     else:
         super().setValue(value)
Esempio n. 7
0
 def setValue(self, value):
     """Set widget value scaled by units.
     """
     if value is MISSING:
         font = QFont()
         font.setItalic(True)
         self.setFont(font)
     elif isinstance(value, Q_):
         super().setValue(value.to(self._units).magnitude)
     else:
         super().setValue(value)
Esempio n. 8
0
    def __init__(self, label_text='', slider_type='float', buttons=False, decimals=3, dragger_steps=None,
                 apply_style=True, main_color=None, *args, **kwargs):
        super(DraggerSlider, self).__init__(*args, **kwargs)

        self._label_text = label_text
        self._main_color = main_color if main_color else QColor(215, 128, 26).getRgb()
        self._dragger_steps = dragger_steps or FLOAT_SLIDER_DRAG_STEPS
        self._is_float = slider_type == 'float'
        self._draggers = None

        self.setFocusPolicy(Qt.StrongFocus)
        if not self._is_float:
            self.setDecimals(0)
            self.setRange(qtutils.FLOAT_RANGE_MIN, qtutils.FLOAT_RANGE_MAX)
        else:
            self.setDecimals(decimals)
            self.setRange(qtutils.INT_RANGE_MIN, qtutils.INT_RANGE_MAX)
        if not buttons:
            self.setButtonSymbols(QAbstractSpinBox.NoButtons)
        if apply_style:
            self._label_font = QFont('Serif', 10, QFont.Bold)
            self.setStyleSheet(self._get_style_sheet())
        else:
            self._label_font = self.lineEdit().font()

        self.lineEdit().installEventFilter(self)
        self.installEventFilter(self)
    def update_complete_list(self, lines=None, extra=None):
        self.clear()
        if lines or extra:
            self.show_me()
            if lines:
                for i in [x for x in lines if not x.name == 'mro']:
                    item = QListWidgetItem(i.name)
                    item.setData(32, i)
                    self.addItem(item)
            if extra:
                font = self.font()
                font.setItalic(True)
                font.setPointSize(font.pointSize() * 0.8)
                for e in extra:
                    item = QListWidgetItem(e.name)
                    item.setData(32, e)
                    item.setFont(font)
                    self.addItem(item)

            font = QFont('monospace', self.line_height, False)
            fm = QFontMetrics(font)
            width = fm.width(' ') * max([len(x.name)
                                         for x in lines or extra]) + 40

            self.resize(max(250, width), 250)
            self.setCurrentRow(0)
        else:
            self.hide_me()
Esempio n. 10
0
    def _drag_pixmap(self, item, items):
        """
        Internal function that shows the pixmap for the given item during drag operation
        :param item: LibraryItem
        :param items: list(LibraryItem)
        :return: QPixmap
        """

        rect = self.visualRect(self.index_from_item(item))
        pixmap = QPixmap()
        pixmap = pixmap.grabWidget(self, rect)
        if len(items) > 1:
            custom_width = 35
            custom_padding = 5
            custom_text = str(len(items))
            custom_x = pixmap.rect().center().x() - float(custom_width * 0.5)
            custom_y = pixmap.rect().top() + custom_padding
            custom_rect = QRect(custom_x, custom_y, custom_width, custom_width)
            painter = QPainter(pixmap)
            painter.setRenderHint(QPainter.Antialiasing)
            painter.setPen(Qt.NoPen)
            painter.setBrush(self.viewer().background_selected_color())
            painter.drawEllipse(custom_rect.center(),
                                float(custom_width * 0.5),
                                float(custom_width * 0.5))
            font = QFont('Serif', 12, QFont.Light)
            painter.setFont(font)
            painter.setPen(self.viewer().text_selected_color())
            painter.drawText(custom_rect, Qt.AlignCenter, str(custom_text))

        return pixmap
Esempio n. 11
0
 def initFontWidget(self):
     self.fontDialog = QFontDialog()
     self.changeFontButton = QPushButton(self)
     self.fontDialog.setCurrentFont(QFont('Sans serif'))
     self.changeFontButton.setText('{0} {1}'.format(
         self.fontDialog.currentFont().family(),
         self.fontDialog.currentFont().pointSize()))
     self.changeFontButton.clicked.connect(self.fontButtonClicked)
Esempio n. 12
0
    def __init__(self, parent=None):
        QTabWidget.__init__(self, parent)

        self._font = QFont('monospace')
        self._texts = dict()
        self._widgets_indexes = dict()

        self.new_tab(DEFAULT_TAB, '')
Esempio n. 13
0
    def __init__(self, controller, desktop=None, parent=None):
        super(ScriptEditor, self).__init__(parent)

        self._controller = controller
        self._font_size = 12
        self._completer = completers.ScriptCompleter(parent=parent,
                                                     editor=self)
        self._desktop = desktop
        self._parent = parent
        self._syntax_highlighter = None
        self._use_jedi = True

        font = QFont(consts.FONT_NAME)
        font.setStyleHint(consts.FONT_STYLE)
        font.setFixedPitch(True)
        self.setFont(font)
        self.document().setDefaultFont(
            QFont(consts.FONT_NAME, consts.MIN_FONT_SIZE, consts.FONT_STYLE))
        metrics = QFontMetrics(self.document().defaultFont())
        self.setTabStopWidth(consts.TAB_STOP * metrics.width(' '))
        self.setAcceptDrops(True)
        self.setWordWrapMode(QTextOption.NoWrap)

        shortcut = QShortcut(QKeySequence('Ctrl+S'), self)
        shortcut.activated.connect(self._test)

        if self._controller.settings:
            self.apply_highlighter(self._controller.settings.get('theme'))

        self.change_font_size(True)
Esempio n. 14
0
    def __init__(self, chart):
        super().__init__(chart)

        self.m_chart = chart
        self.m_text = ""
        self.m_textRect = QRectF()
        self.m_rect = QRectF()
        self.m_anchor = QPointF()
        self.m_font = QFont()
Esempio n. 15
0
    def __init__(self, text, root_tag):
        super(WidgetsFromTextParser, self).__init__()

        self._widgets = list()
        self._root_tag = root_tag

        self._constructed = ''
        self._font = QFont('sans')

        self.feed(text)
Esempio n. 16
0
 def font(self, prefix, size):
     """Return a QFont corresponding to the given prefix and size."""
     font = QFont(self.fontname[prefix])
     font.setPixelSize(size)
     if prefix[-1] == 's':  # solid style
         font.setStyleName('Solid')
     return font
Esempio n. 17
0
    def __init__(self, commands=[], parent=None):
        super(ConsoleInput, self).__init__(parent=parent)

        self._commands = commands

        self._model = QStringListModel()
        self._model.setStringList(self._commands)
        self._completer = QCompleter(self)
        self._completer.setModel(self._model)
        self._completer.setCompletionMode(QCompleter.PopupCompletion)
        self._completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.setCompleter(self._completer)
        self.setFont(QFont('Arial', 9, QFont.Bold, False))
Esempio n. 18
0
    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)
Esempio n. 19
0
    def __init__(self, title='', parent=None):
        super(ExpandableGroup, self).__init__(title, parent)

        self.close_btn = QPushButton('-', self)
        self.close_btn.clicked.connect(self.toggle)

        self.setMouseTracking(True)

        self.setFont(QFont('Verdana', 10, QFont.Bold))
        self.setTitle('     ' + self.title())

        self.expanded = True

        self.hitbox = QRect(0, 0, self.width(), 18)
Esempio n. 20
0
    def __init__(self):
        font = QFont()
        font.setPointSize(8)
        font.setFamily("Calibri")
        self.setFont(font)

        self._hover = False
        self._glow_index = 0
        self._anim_timer = QTimer()
        self._anim_timer.timeout.connect(self._animate_glow)
Esempio n. 21
0
    def __init__(self, settings=None, parent=None):

        self._settings = settings
        self._text_edit_globals = dict()
        self._file_path = None
        self._last_modified = None
        self._find_widget = None
        self._completer = None
        self._skip_focus = False

        self._option_object = None

        super(CodeTextEdit, self).__init__(parent=parent)

        self.setFont(QFont('Courier', 9))
        self.setWordWrapMode(QTextOption.NoWrap)

        save_shortcut = QShortcut(QKeySequence(self.tr('Ctlr+s')), self)
        find_shortcut = QShortcut(QKeySequence(self.tr('Ctrl+f')), self)
        goto_line_shortcut = QShortcut(QKeySequence(self.tr('Ctrl+g')), self)
        duplicate_line_shortcut = QShortcut(QKeySequence(self.tr('Ctrl+d')),
                                            self)
        zoom_in_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Plus), self)
        zoom_in_other_shortcut = QShortcut(
            QKeySequence(Qt.CTRL + Qt.Key_Equal), self)
        zoom_out_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_Minus),
                                      self)

        save_shortcut.activated.connect(self._on_save)
        find_shortcut.activated.connect(self._on_find)
        goto_line_shortcut.activated.connect(self._on_goto_line)
        duplicate_line_shortcut.activated.connect(self._on_duplicate_line)
        zoom_in_shortcut.activated.connect(self._zoom_in_text)
        zoom_in_other_shortcut.activated.connect(self._zoom_in_text)
        zoom_out_shortcut.activated.connect(self._zoom_out_text)

        self._line_numbers = CodeLineNumber(self)

        self._setup_highlighter()
        self._update_number_width(0)
        self._line_number_highlight()

        self.blockCountChanged.connect(self._on_update_number_width)
        self.updateRequest.connect(self._on_update_number_area)
        self.cursorPositionChanged.connect(self._on_cursor_position_changed)
        self.codeTextSizeChanged.connect(self._on_code_text_size_changed)
Esempio n. 22
0
    def __init__(self, *args, **kwargs):
        super(LineNumbers, self).__init__(*args)

        self.textWidget = self.doc = None
        self.setTextWidget(kwargs.pop('widget', None))

        # Monospaced font to keep width from shifting.
        font = QFont()
        font.setStyleHint(QFont.Courier)
        font.setFamily("Monospace")
        self.setFont(font)

        self.updateAndResize()
Esempio n. 23
0
    def __init__(self, parent=None):
        super(OutputConsole, self).__init__(parent)

        self.setWordWrapMode(QTextOption.NoWrap)
        font = QFont('Courier')
        font.setStyleHint(QFont.Monospace)
        font.setFixedPitch(True)
        self.setFont(font)
        self._font_size = 14
        self.document().setDefaultFont(
            QFont('Courier', self._font_size, QFont.Monospace))
        metrics = QFontMetrics(self.document().defaultFont())
        self.setTabStopWidth(4 * metrics.width(' '))
        self.setMouseTracking(True)
        self.setReadOnly(True)

        self.textChanged.connect(self._on_text_changed)
Esempio n. 24
0
    def __init__(self,
                 name,
                 color=_DEFAULT_OBJECT_COLOR,
                 border_color=_DEFAULT_OBJECT_BORDER_COLOR,
                 parent=None):
        super(BaseObjectItem, self).__init__(parent)

        self._name = name
        self._children = list()
        self._parent = parent
        self._color = color
        self._border_color = border_color
        self._font = QFont('Tahoma', 9.0)
        self._font_color = QColor(Qt.black)
        self._is_hovered = False
        self._is_double_clicked = False

        if parent:
            self.setParent(parent)
            parent.add_child(self)  # TODO: Remove this?
Esempio n. 25
0
 def init_ui(self):
     self.text_edit = QTextEdit(self)
     self.setCentralWidget(self.text_edit)
     
     font = QFont("Menlo", 12)
     # TODO: Create a layout and change the line spacing
     #spacing = QFontMetrics(font).lineSpacing()
     self.text_edit.setFont(font)
     self.highlighter = Highlighter(self.text_edit.document(), DEFAULT_RULES, DEFAULT_STYLE)
     #print("Highlighter doc: {}".format(self.text_edit.document()))
     
     menu_bar = self.menuBar()
     m_file = menu_bar.addMenu("File")
     
     i_open = QAction("Open", self)
     i_open.setShortcut('Ctrl+O')
     i_open.triggered.connect(self.on_open)
     
     m_file.addAction(i_open)
     
     self.setGeometry(300, 300, 350, 300)
     self.setWindowTitle("tea")
Esempio n. 26
0
 def on_set_clicked(self):
     font = QFont()
     font.setItalic(False)
     self._widget.setFont(font)
     self._widget.value_to_feat()
Esempio n. 27
0
    def paint(self, painter, option, widget):
        fillColor = self.color
        if option.state & QStyle.State_Selected:
            fillColor = self.color.darker(150)
        if option.state & QStyle.State_MouseOver:
            fillColor = fillColor.lighter(125)

        lod = option.levelOfDetailFromTransform(painter.worldTransform())
        if lod < 0.2:
            if lod < 0.125:
                painter.fillRect(QRectF(0, 0, 110, 70), fillColor)
                return
            b = painter.brush()
            painter.setBrush(fillColor)
            painter.drawRect(13, 13, 97, 57)
            painter.setBrush(b)
            return

        oldPen = painter.pen()
        pen = oldPen
        width = 0
        if option.state & QStyle.State_Selected:
            width += 2

        pen.setWidth(width)
        b = painter.brush()
        painter.setBrush(
            QBrush(
                fillColor.darker(120 if (option.state
                                         & QStyle.State_Sunken) else 100)))

        painter.drawRect(QRect(14, 14, 79, 39))
        painter.setBrush(b)

        if lod >= 1:
            painter.setPen(QPen(Qt.gray, 1))
            painter.drawLine(15, 54, 94, 54)
            painter.drawLine(94, 53, 94, 15)
            painter.setPen(QPen(Qt.black, 0))

        # Draw text
        if lod >= 2:
            font = QFont("Times", 10)
            font.setStyleStrategy(QFont.ForceOutline)
            painter.setFont(font)
            painter.save()
            painter.scale(0.1, 0.1)
            painter.drawText(
                170, 180, "Model: VSC-2000 (Very Small Chip) at {}x{}".format(
                    self.x, self.y))
            painter.drawText(170, 200,
                             "Serial number: DLWR-WEER-123L-ZZ33-SDSJ")
            painter.drawText(170, 220, "Manufacturer: Chip Manufacturer")
            painter.restore()

        # Draw lines
        lines = []  # QVarLengthArray < QLineF, 36 >
        if lod >= 0.5:
            for i in range(
                    0, 11, 1 if lod > 0.5 else
                    2):  # (int i = 0 i <= 10 i += (1 if lod > 0.5 else 2)):
                lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5))
                lines.append(QLineF(18 + 7 * i, 54, 18 + 7 * i, 62))

            for i in range(0, 6, 1 if lod > 0.5 else
                           2):  # (int i = 0 i <= 6 i += (lod > 0.5 ? 1: 2)) {
                lines.append(QLineF(5, 18 + i * 5, 13, 18 + i * 5))
                lines.append(QLineF(94, 18 + i * 5, 102, 18 + i * 5))

        if lod >= 0.4:
            lineData = [
                QLineF(25, 35, 35, 35),
                QLineF(35, 30, 35, 40),
                QLineF(35, 30, 45, 35),
                QLineF(35, 40, 45, 35),
                QLineF(45, 30, 45, 40),
                QLineF(45, 35, 55, 35)
            ]
            lines.extend(lineData)

        painter.drawLines(lines)

        # Draw red ink
        if len(self.stuff) > 1:
            p = painter.pen()
            painter.setPen(
                QPen(Qt.red, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin))
            painter.setBrush(Qt.NoBrush)

            path = QPainterPath
            path.moveTo(self.stuff[0])
            for i in range(1, len(self.stuff)):
                path.lineTo(self.stuff[i])
                painter.drawPath(path)
                painter.setPen(p)
        """
Esempio n. 28
0
    def ui(self):
        super(ToolsetWidget, self).ui()

        self.setContentsMargins(0, 0, 0, 0)
        self._contents_layout.setContentsMargins(0, 0, 0, 0)
        self._contents_layout.setSpacing(0)

        self._stacked_widget = stack.SlidingOpacityStackedWidget(self)
        # NOTE: tpDcc style uses this objectName to apply specific style to this widget
        self._stacked_widget.setObjectName('toolsetStackedWidget')
        self._stacked_widget.setContentsMargins(0, 0, 0, 0)
        self._stacked_widget.setLineWidth(0)
        self.main_layout.addWidget(self._stacked_widget)

        self.show_expand_indicator(False)
        self.set_title_text_mouse_transparent(True)

        self._display_mode_button = DisplayModeButton(color=self._icon_color,
                                                      size=16,
                                                      parent=self)
        self._display_mode_button.setFixedSize(QSize(22, 22))
        self._connect_button = buttons.BaseToolButton(
            parent=self).image('connect').icon_only()
        self._connect_button.setFixedSize(QSize(22, 22))
        self._connect_button.setEnabled(False)
        self._connect_button.setToolTip('No connected to any DCC')
        self._manual_button = buttons.BaseMenuButton(parent=self)
        self._manual_button.set_icon(resources.icon('manual'))
        self._manual_button.setFixedSize(QSize(22, 22))
        self._help_button = buttons.BaseMenuButton(parent=self)
        self._help_button.set_icon(resources.icon('help'))
        self._help_button.setFixedSize(QSize(22, 22))
        self._help_switch = switch.SwitchWidget(parent=self)
        self._settings_button = buttons.BaseMenuButton(parent=self)
        self._settings_button.set_icon(resources.icon('settings'))
        self._settings_button.setFixedSize(QSize(22, 22))
        self._help_widget = ToolsetHelpWidget()

        empty_widget = QWidget()
        empty_layout = layouts.HorizontalLayout(spacing=0,
                                                margins=(0, 0, 0, 0))
        empty_widget.setLayout(empty_layout)
        empty_layout.addStretch()
        empty_label = label.BaseLabel('Tool has no UI')
        empty_label.theme_level = label.BaseLabel.Levels.H1
        empty_layout.addWidget(empty_label)
        empty_layout.addStretch()

        self._preferences_widget = preferences.PreferencesWidget(parent=self)

        # We call if after setting all buttons
        self.set_icon_color(self._icon_color)

        self.visual_update(collapse=True)

        self._dccs_menu = QMenu(self)

        display_button_pos = 7
        self._title_frame.horizontal_layout.insertWidget(
            display_button_pos - 1, self._manual_button)
        self._title_frame.horizontal_layout.insertWidget(
            display_button_pos - 1, self._help_switch)
        self._title_frame.horizontal_layout.insertWidget(
            display_button_pos - 1, self._help_button)
        self._title_frame.horizontal_layout.insertWidget(
            display_button_pos - 1, self._settings_button)
        self._title_frame.horizontal_layout.insertWidget(
            0, self._connect_button)
        self._title_frame.horizontal_layout.insertWidget(
            display_button_pos, self._display_mode_button)
        self._title_frame.horizontal_layout.setSpacing(0)
        self._title_frame.horizontal_layout.setContentsMargins(0, 0, 0, 0)
        self._title_frame.delete_button.setIconSize(QSize(12, 12))
        self._title_frame.item_icon_button.setIconSize(QSize(20, 20))

        font = QFont()
        font.setBold(True)
        self.setFont(font)

        if not dcc.is_standalone():
            self._connect_button.setVisible(False)

        self._stacked_widget.addWidget(empty_widget)
        self._stacked_widget.addWidget(self._widget_hider)
        self._stacked_widget.addWidget(self._preferences_widget)

        self._widget_hider.setVisible(False)
        self._preferences_widget.setVisible(False)
Esempio n. 29
0
 def _zoom_out_text(self):
     font = self.font()
     size = font.pointSize()
     size -= 1
     font.setPointSize(size)
     self.setFont(QFont('Courier', size))
Esempio n. 30
0
 def font(self, prefix, size):
     """Return a QFont corresponding to the given prefix and size."""
     font = QFont(self.fontname[prefix])
     font.setPixelSize(size)
     return font
Esempio n. 31
0
            return rst


from Qt.QtCore import Qt, QSize, Slot, Signal, Property
from Qt.QtGui import (QApplication, QDialog, QWidget, QFont, QSizePolicy,
                      QColor, QPalette, QToolTip, QMessageBox, QLabel,
                      QPushButton, QDialogButtonBox, QLayout, QHBoxLayout,
                      QVBoxLayout, QFormLayout, QFrame, QTabWidget, QLineEdit,
                      QSpinBox, QDoubleSpinBox, QLCDNumber, QDial,
                      QProgressBar, QSlider, QScrollBar, QComboBox, QCheckBox)

from .. import Q_, Driver
from ..feat import MISSING, DictFeat
from ..log import get_logger

QToolTip.setFont(QFont('SansSerif', 10))

logger = get_logger('lantz.ui', False)


def _rst_to_html(rst):
    """Convert rst docstring to HTML.
    """
    parts = doc_core.publish_parts(rst, writer_name="html")
    return parts['body']


def _params_doc(rst):
    """Extract
    """
    if not rst:
Esempio n. 32
0
 def on_set_clicked(self):
     font = QFont()
     font.setItalic(False)
     self._widget.setFont(font)
     self._widget.value_to_feat()