Python PyQt5.QtGui.QFont() Examples

The following are code examples for showing how to use PyQt5.QtGui.QFont(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Danmu.py    MIT License 6 votes vote down vote up
def __init__(self, text, color, top, window):
        super(Danmu, self).__init__(window)
        # clean invalid characters
        text = re.sub(r'/Emoji\d+|/表情|^ | $', '',
                      text.replace('\n', ' '))[0:MAX_STR_LEN]
        self.top = top
        self.setTextFormat(Qt.PlainText)
        self.setText(text)
        # self.setWindowFlags(Qt.FramelessWindowHint)
        # self.setAttribute(Qt.WA_TranslucentBackground)
        self.setAttribute(Qt.WA_TransparentForMouseEvents, True)
        self.setFont(QFont('SimHei', FONT_SIZE, 100))
        # set size of label
        myRect = self.fontMetrics().boundingRect(text)
        self.setFixedSize(myRect.width() + 20, myRect.height() + 10)
        self.setColor(color)
        self.setShadow(QColor('#060606'), 5, 1.5)
        # self.setStyleSheet("border:1px solid red;") 
Example 2
Project: dcc   Author: amimo   File: sourcewindow.py    Apache License 2.0 6 votes vote down vote up
def _get_format_from_style(self, token, style):
        """ Returns a QTextCharFormat for token by reading a Pygments style.
        """
        result = QtGui.QTextCharFormat()
        for key, value in list(style.style_for_token(token).items()):
            if value:
                if key == 'color':
                    result.setForeground(self._get_brush(value))
                elif key == 'bgcolor':
                    result.setBackground(self._get_brush(value))
                elif key == 'bold':
                    result.setFontWeight(QtGui.QFont.Bold)
                elif key == 'italic':
                    result.setFontItalic(True)
                elif key == 'underline':
                    result.setUnderlineStyle(
                        QtGui.QTextCharFormat.SingleUnderline)
                elif key == 'sans':
                    result.setFontStyleHint(QtGui.QFont.SansSerif)
                elif key == 'roman':
                    result.setFontStyleHint(QtGui.QFont.Times)
                elif key == 'mono':
                    result.setFontStyleHint(QtGui.QFont.TypeWriter)
        return result 
Example 3
Project: kucher   Author: Zubax   File: utils.py    GNU General Public License v3.0 6 votes vote down vote up
def _get_monospace_font_impl(small=False) -> QFont:
    begun = time.monotonic()
    multiplier = 0.8 if small else 1.0
    min_font_size = min(7, QFont().pointSize())
    preferred = ['Consolas', 'DejaVu Sans Mono', 'Monospace', 'Lucida Console', 'Monaco']
    for name in preferred:
        font = QFont(name)
        if QFontInfo(font).fixedPitch():
            font.setPointSize(round(max(min_font_size, QFont().pointSize() * multiplier)))
            _logger.info('Selected monospace font (%.6f seconds): %r', time.monotonic() - begun, font.toString())
            return font

    font = QFont()
    font.setStyleHint(QFont().Monospace)
    font.setFamily('monospace')
    _logger.info('Using fallback monospace font (%.6f seconds): %r', time.monotonic() - begun, font.toString())
    return font 
Example 4
Project: kucher   Author: Zubax   File: group_box_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def set_icon(self, icon_name: str):
        if self._current_icon == icon_name:
            return

        _logger.debug('Changing icon from %r to %r', self._current_icon, icon_name)
        self._current_icon = icon_name

        icon_size = QFontMetrics(QFont()).height()
        icon_path = get_icon_path(icon_name)

        # This hack adds a custom icon to the GroupBox: make it checkable, and then, using styling, override
        # the image of the check box with the custom icon.
        self.setCheckable(True)     # This is needed to make the icon visible
        self.setStyleSheet(f'''
            QGroupBox::indicator {{
                width:  {icon_size}px;
                height: {icon_size}px;
                image: url({icon_path});
            }}
        ''')

        # We don't actually want it to be checkable, so override this thing to return it back to normal again
        # noinspection PyUnresolvedReferences
        self.toggled.connect(lambda _: self.setChecked(True)) 
Example 5
Project: Python-GUI   Author: arpitj07   File: Project.py    MIT License 6 votes vote down vote up
def boxclose(self):
        teamname = self.open_screen.OpenTheTeam.text()
        myteam= sqlite3.connect('TEAM.db')
        curser= myteam.cursor()
        curser.execute("SELECT PLAYERS from team WHERE NAMES= '"+teamname+"';")
        hu= curser.fetchall()
        self.listWidget.clear()
        for i in range(len(hu)):
            item= QtWidgets.QListWidgetItem(hu[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('sea green'))
            self.listWidget.addItem(item)
            
        self.openDialog.close() 
Example 6
Project: Python-GUI   Author: arpitj07   File: scorewidnow.py    MIT License 6 votes vote down vote up
def setupUi(self, ScoreWindow):
        ScoreWindow.setObjectName("ScoreWindow")
        ScoreWindow.resize(471, 386)
        self.centralwidget = QtWidgets.QWidget(ScoreWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.Score = QtWidgets.QLineEdit(self.centralwidget)
        self.Score.setGeometry(QtCore.QRect(180, 180, 113, 22))
        self.Score.setObjectName("Score")
        self.teamscore = QtWidgets.QLabel(self.centralwidget)
        self.teamscore.setGeometry(QtCore.QRect(180, 130, 151, 20))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.teamscore.setFont(font)
        self.teamscore.setObjectName("teamscore")
        ScoreWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(ScoreWindow)
        self.statusbar.setObjectName("statusbar")
        ScoreWindow.setStatusBar(self.statusbar)

        self.retranslateUi(ScoreWindow)
        QtCore.QMetaObject.connectSlotsByName(ScoreWindow) 
Example 7
Project: HippMapp3r   Author: mgoubran   File: gui_options.py    GNU General Public License v3.0 6 votes vote down vote up
def print_help(main, helpfun):
    main.setWindowTitle('Help function')
    scrollarea = QtWidgets.QScrollArea()

    helplbl = QtWidgets.QLabel()
    helplbl.setText(helpfun)
    font = QtGui.QFont('Mono', 9, QtGui.QFont.Light)
    helplbl.setFont(font)
    helplbl.setWordWrap(True)

    scrollarea.setWidget(helplbl)
    #scrollarea.setWidgetResizable(False)
    scrollarea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
    scrollarea.setAttribute(QtCore.Qt.WA_DeleteOnClose)
    main.setCentralWidget(scrollarea)

    main.move(QtWidgets.QApplication.desktop().screen().rect().center() - main.rect().center())
    main.show()

    QtWidgets.QApplication.processEvents() 
Example 8
Project: eddy   Author: obdasystems   File: Unsatisfiable_Entity_Explorer.py    GNU General Public License v3.0 6 votes vote down vote up
def doAddExplanation(self, node, explanation):

        if explanation is not None and len(explanation)>0:
            exp_to_add = QtGui.QStandardItem()
            exp_to_add.setText('<Explanation(s)> \n**(click to open Explanation Explorer)')

            font = QtGui.QFont()
            font.setBold(True)
            font.setItalic(True)
            font.setUnderline(True)

            exp_to_add.setFont(font)

            exp_to_add.setData(explanation)
            parent = self.parentFor(node)
            parent.appendRow(exp_to_add) 
Example 9
Project: dunya-desktop   Author: MTG   File: table.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None):
        QTableView.__init__(self, parent=parent)

        # setting the table for no edit and row selection
        self.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        # self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setMouseTracking(True)
        self.horizontalHeader().setStretchLastSection(True)
        font = QFont()
        font.setPointSize(13)
        self.horizontalHeader().setFont(font)

        # hiding the vertical headers
        self.verticalHeader().hide()

        # arranging the artist column for being multi-line
        self.setWordWrap(True)
        self.setTextElideMode(Qt.ElideMiddle)

        self._last_index = QPersistentModelIndex()
        self.viewport().installEventFilter(self)

        self._set_font() 
Example 10
Project: hexutil   Author: stephanh42   File: example.py    MIT License 6 votes vote down vote up
def __init__(self, *args, **kws):
        super().__init__(*args, **kws)
        self.setMouseTracking(True) # we want to receive mouseMoveEvents

        self.level = Level(500)
        self.player = hexutil.origin
        self.hexgrid = hexutil.HexGrid(24)

        # initialize GUI objects needed for painting
        self.font = QtGui.QFont("Helvetica", 20)
        self.font.setStyleHint(QtGui.QFont.SansSerif)
        self.pen = QtGui.QPen()
        self.pen.setWidth(2)
        self.select_brush = QtGui.QBrush(QtGui.QColor(127, 127, 255, 127))
        self.unseen_brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 127))

        self.update_fov() 
Example 11
Project: plexdesktop   Author: coryo   File: delegates.py    GNU General Public License v3.0 6 votes vote down vote up
def placeholder_thumb_generator(title, size=150):
    """Returns a QPixmap of size with the first letter of each word in title"""
    initials = ' '.join([x[0] for x in title.split(' ') if len(x) > 2])
    key = 'placeholder' + initials
    img = QtGui.QPixmapCache.find(key)
    if img:
        return img
    qsize = QtCore.QSize(size, size)
    circle_color = QtGui.QColor(50, 50, 50)
    text_color = QtGui.QColor(75, 75, 75)
    rect = QtCore.QRect(QtCore.QPoint(0, 0), QtCore.QPoint(size, size))
    center = QtCore.QPoint(size / 2, size / 2)
    img = QtGui.QPixmap(qsize)
    img.fill(QtCore.Qt.transparent)
    p = QtGui.QPainter(img)
    p.setFont(QtGui.QFont('Open Sans', size / 4, weight=QtGui.QFont.Bold))
    p.setBrush(QtGui.QBrush(circle_color))
    p.setPen(circle_color)
    p.setRenderHint(QtGui.QPainter.Antialiasing, True)
    p.drawEllipse(center, size / 2 - 1, size / 2 - 1)
    p.setPen(text_color)
    p.drawText(rect, QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter, initials)
    QtGui.QPixmapCache.insert(key, img)
    return img 
Example 12
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Marquee.py    MIT License 5 votes vote down vote up
def initUi(self, text, color, screenWidth, screenHeight):
        # self.setStyleSheet("border:1px solid blue;")
        self.doubleText = text + " " + text
        self.setFont(QFont('SimHei', 24, 100))
        self.myRect = self.fontMetrics().boundingRect(text)
        self.setGeometry(screenWidth - self.FIXED_WIDTH - 40,
                         screenHeight - self.height() - 60,
                         self.FIXED_WIDTH + 20,
                         self.myRect.height() + 10)
        self.initLabel(self.label, self.doubleText)
        self.label.anim = QPropertyAnimation(self.label, b'geometry')
        self.label.anim.setDuration(self.ANIM_TIME)
        self.label.anim.setStartValue(
            QRect(
                0, 0,
                self.fontMetrics().boundingRect(self.doubleText).width() + 20,
                self.myRect.height() + 10))
        self.label.anim.setEndValue(
            QRect(
                -(self.myRect.width() + 20), 0,
                self.fontMetrics().boundingRect(self.doubleText).width() + 20,
                self.myRect.height() + 10))
        self.label.anim.setLoopCount(-1)
        self.label.anim.start()
        # self.label.setStyleSheet("border:1px solid red;")
        self.setChangeRGB(self.RAINBOW_RGB_LIST[self.clrIdx],
                          self.RAINBOW_RGB_LIST[(self.clrIdx + 1) % 7])
        self.label.show() 
Example 13
Project: JI-Live-Danmu-Client   Author: SJTU-UMJI-Tech   File: Marquee.py    MIT License 5 votes vote down vote up
def initLabel(self, label, text):
        label.setText(text)
        label.setFont(QFont('SimHei', 24, 100))
        eff = QGraphicsDropShadowEffect()
        eff.setColor(QColor(6, 6, 6))
        eff.setBlurRadius(5)
        eff.setOffset(1.5, 1.5)
        label.setGraphicsEffect(eff)
        label.setGeometry(0, 0,
                          self.fontMetrics().boundingRect(text).width() + 20,
                          self.fontMetrics().boundingRect(text).height() + 10) 
Example 14
Project: dcc   Author: amimo   File: sourcewindow.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, parent=None, lines=[]):
        super(SourceDocument, self).__init__(parent)
        self.parent = parent

        self.setDefaultFont(QtGui.QFont('Monaco', 9, QtGui.QFont.Light))

        cursor = QtGui.QTextCursor(self)  # position=0x0
        self.binding = {}

        # save the cursor position before each interesting element
        for section, L in lines:
            for t in L:
                if t[0] in BINDINGS_NAMES:
                    self.binding[cursor.position()] = t
                cursor.insertText(t[1]) 
Example 15
Project: pymovie   Author: bob-anderson-ok   File: aperturesFileTagDialog.py    MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(600, 102)
        Dialog.setMinimumSize(QtCore.QSize(400, 0))
        Dialog.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.apertureGroupTagEdit = QtWidgets.QLineEdit(Dialog)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.apertureGroupTagEdit.setFont(font)
        self.apertureGroupTagEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.apertureGroupTagEdit.setMaxLength(80)
        self.apertureGroupTagEdit.setObjectName("apertureGroupTagEdit")
        self.verticalLayout.addWidget(self.apertureGroupTagEdit)
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Vertical)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setCenterButtons(True)
        self.buttonBox.setObjectName("buttonBox")
        self.horizontalLayout.addWidget(self.buttonBox)
        self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example 16
Project: pymovie   Author: bob-anderson-ok   File: apertureNameDialog.py    MIT License 5 votes vote down vote up
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(609, 84)
        Dialog.setMinimumSize(QtCore.QSize(600, 0))
        Dialog.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.gridLayout = QtWidgets.QGridLayout(Dialog)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.apertureNameEdit = QtWidgets.QLineEdit(Dialog)
        font = QtGui.QFont()
        font.setPointSize(13)
        self.apertureNameEdit.setFont(font)
        self.apertureNameEdit.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.apertureNameEdit.setMaxLength(80)
        self.apertureNameEdit.setObjectName("apertureNameEdit")
        self.verticalLayout.addWidget(self.apertureNameEdit)
        self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1)
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setOrientation(QtCore.Qt.Vertical)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 0, 1, 1, 1)

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
Example 17
Project: kucher   Author: Zubax   File: utils.py    GNU General Public License v3.0 5 votes vote down vote up
def get_monospace_font(small=False) -> QFont:
    # We have to copy the result because we don't want to share the same instance globally - users may mutate it
    return QFont(_get_monospace_font_impl(small)) 
Example 18
Project: kucher   Author: Zubax   File: utils.py    GNU General Public License v3.0 5 votes vote down vote up
def _unittest_icons():
    import math
    import glob
    from PyQt5.QtWidgets import QApplication, QMainWindow, QGroupBox, QGridLayout, QLabel, QSizePolicy
    from PyQt5.QtGui import QFont, QFontMetrics

    app = QApplication([])

    all_icons = list(map(lambda x: os.path.splitext(os.path.basename(x))[0],
                         glob.glob(os.path.join(get_absolute_path('view', 'icons'), '*'))))
    print('All icons:', len(all_icons), all_icons)

    grid_size = int(math.ceil(math.sqrt(len(all_icons))))

    icon_size = QFontMetrics(QFont()).height()

    def render_icon(name: str, row: int, col: int):
        icon = get_icon(name)
        icon_label = QLabel()
        icon_label.setAlignment(Qt.AlignCenter)
        icon_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        icon_label.setPixmap(icon.pixmap(icon_size, icon_size))
        layout.addWidget(icon_label, row, col)

    win = QMainWindow()
    container = QGroupBox(win)
    layout = QGridLayout()

    for idx, ic in enumerate(all_icons):
        render_icon(ic, idx // grid_size, idx % grid_size)

    container.setLayout(layout)
    win.setCentralWidget(container)
    win.show()

    for _ in range(1000):
        time.sleep(0.005)
        app.processEvents()

    win.close() 
Example 19
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_TableModel, self).__init__(parent)

        self._data: TaskStatisticsView = TaskStatisticsView()

        self._icon_size = QFontMetrics(QFont()).height() 
Example 20
Project: kucher   Author: Zubax   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def headerData(self, section: int, orientation: int, role=None):
        if role == Qt.DisplayRole:
            if orientation == Qt.Horizontal:
                return self.COLUMNS[section][0]
            else:
                task_enum = list(self._data.entries.keys())[section]
                return get_human_friendly_task_name(task_enum, short=True)

        if role in (Qt.ToolTipRole, Qt.StatusTipRole):
            if orientation == Qt.Horizontal:
                return self.COLUMNS[section][1]
            else:
                task_enum = list(self._data.entries.keys())[section]
                return get_human_friendly_task_name(task_enum)

        if role == Qt.DecorationRole:
            if orientation == Qt.Vertical:
                task_enum = list(self._data.entries.keys())[section]
                try:
                    icon_name = get_icon_name_for_task_id(task_enum)
                except KeyError:
                    pass
                else:
                    return get_icon_pixmap(icon_name, self._icon_size)

        if role == Qt.TextAlignmentRole:
            return Qt.AlignCenter

        if role == Qt.FontRole:
            if orientation == Qt.Vertical:
                if list(self._data.entries.keys())[section] == self._get_running_task_id():
                    font = QFont()
                    font.setBold(True)
                    return font

        return QVariant() 
Example 21
Project: kucher   Author: Zubax   File: placeholder_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(PlaceholderWidget, self).__init__(parent)

        label = QLabel(self)
        label.setText('Task-specific status information is not available')
        label.setWordWrap(True)
        label.setAlignment(Qt.AlignCenter)

        font: QFont = label.font()
        font.setItalic(True)
        label.setFont(font)

        layout = QVBoxLayout()
        layout.addWidget(label)
        self.setLayout(layout) 
Example 22
Project: kucher   Author: Zubax   File: fault_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(Widget, self).__init__(parent)

        self._last_displayed: TaskSpecificStatusReport.Fault = None

        self._line_height = QFontMetrics(QFont()).height()

        self._task_icon_display = QLabel(self)
        self._task_name_display = self._make_line_display()

        self._error_code_dec = self._make_line_display('Exit code in decimal')
        self._error_code_hex = self._make_line_display('Same exit code in hexadecimal')
        self._error_code_bin = self._make_line_display('Same exit code in binary, for extra convenience')

        self._error_description_display = self._make_line_display('Error description', False)
        self._error_comment_display = self._make_text_display()

        self.setLayout(
            lay_out_vertically(
                lay_out_horizontally(QLabel('The task', self),
                                     self._task_icon_display,
                                     (self._task_name_display, 3)),
                lay_out_horizontally(QLabel('has failed with exit code', self),
                                     (self._error_code_dec, 1),
                                     (self._error_code_hex, 1),
                                     (self._error_code_bin, 2),
                                     QLabel('which means:', self)),
                lay_out_horizontally((self._error_description_display, 1)),
                lay_out_horizontally((self._error_comment_display, 1)),
                (None, 1),
            )
        ) 
Example 23
Project: kucher   Author: Zubax   File: run_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_DQDisplayWidget, self).__init__(parent)

        def make_label(text: str = '') -> QLabel:
            w = QLabel(text, self)
            w.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
            font = QFont()
            font.setBold(True)
            w.setFont(font)
            return w

        self._ud = make_label()
        self._uq = make_label()
        self._id = make_label()
        self._iq = make_label()

        self._ud.setToolTip('Direct axis voltage')
        self._uq.setToolTip('Quadrature axis voltage')
        self._id.setToolTip('Direct axis current')
        self._iq.setToolTip('Quadrature axis current')

        # 0  1  2
        # 1 Ud Uq
        # 2 Id Iq
        layout = QGridLayout(self)
        layout.addWidget(QLabel('U<sub>DQ</sub>', self), 0, 0)
        layout.addWidget(QLabel('I<sub>DQ</sub>', self), 1, 0)
        layout.addWidget(self._ud, 0, 1)
        layout.addWidget(self._uq, 0, 2)
        layout.addWidget(self._id, 1, 1)
        layout.addWidget(self._iq, 1, 2)
        layout.addWidget(make_label('V'), 0, 3)
        layout.addWidget(make_label('A'), 1, 3)
        layout.setColumnStretch(0, 4)
        layout.setColumnStretch(1, 2)
        layout.setColumnStretch(2, 2)
        layout.setColumnStretch(3, 1)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout) 
Example 24
Project: kucher   Author: Zubax   File: run_status_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def _make_vertical_separator(parent: QWidget) -> QWidget:
    # https://stackoverflow.com/questions/10053839/how-does-designer-create-a-line-widget
    line = QFrame(parent)
    line.setFrameShape(QFrame.VLine)
    line.setStyleSheet('QFrame { color: palette(mid); };')
    line.setMinimumWidth(QFontMetrics(QFont()).width('__') * 2)
    return line 
Example 25
Project: kucher   Author: Zubax   File: model.py    GNU General Public License v3.0 5 votes vote down vote up
def get_font() -> QFont:
        return get_monospace_font(small=True) 
Example 26
Project: kucher   Author: Zubax   File: model.py    GNU General Public License v3.0 5 votes vote down vote up
def _data_font(self, index: QModelIndex) -> QFont:
        row, column = index.row(), index.column()
        node = self._unwrap(index)

        if column == self.ColumnIndices.VALUE:
            if node.state == node.State.PENDING:
                return self._italic_font

            if self.flags(index) & Qt.ItemIsEditable:
                return self._underlined_font

        return self._regular_font 
Example 27
Project: kucher   Author: Zubax   File: value_display_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,
                 parent: QWidget,
                 title: str,
                 placeholder_text: typing.Optional[str] = None,
                 with_comment: bool = False,
                 tooltip: typing.Optional[str] = None):
        super(ValueDisplayWidget, self).__init__(parent)

        self._placeholder_text = str(placeholder_text or '')

        self._value_display = QLabel(self)
        self._value_display.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
        bold_font = QFont()
        bold_font.setBold(True)
        self._value_display.setFont(bold_font)

        if with_comment:
            self._comment = _Comment(self)
        else:
            self._comment = None

        self._default_tooltip = str(tooltip or '')
        self.setToolTip(self._default_tooltip)
        self.setStatusTip(self.toolTip())

        title_label = QLabel(title)
        title_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)

        layout = QHBoxLayout()
        layout.addWidget(title_label, 1)
        layout.addWidget(self._value_display, 1)
        if self._comment is not None:
            layout.addWidget(self._comment)

        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.reset() 
Example 28
Project: kucher   Author: Zubax   File: value_display_widget.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent: QWidget):
        super(_Comment, self).__init__(parent)
        self.setAlignment(Qt.AlignCenter)
        self._icon_size = QFontMetrics(QFont()).height()        # As large as font
        self._pixmap_cache: typing.Dict[str, QPixmap] = {}
        self._current_icon_name: typing.Optional[str] = None
        # Initializing defaults
        self.reset() 
Example 29
Project: geoscience   Author: rolandhill   File: SectionGrid.py    GNU General Public License v3.0 5 votes vote down vote up
def setStyle(self, layer, labelSuffix='', labels=True):
        # Set the line style
        r = layer.renderer()
        r.symbol().setColor(QtGui.QColor('grey'))
        r.symbol().setOpacity(0.5)

        #Set the label style
        if labels:
            settings = QgsPalLayerSettings()
            textFormat = QgsTextFormat()
            textFormat.setFont(QtGui.QFont("Arial", 10))
            textFormat.setColor(QtGui.QColor('grey'))
            textFormat.setOpacity(0.5)
            settings.setFormat(textFormat)
            if labelSuffix == '':
                settings.fieldName = 'Label'
            else:
    #            settings.fieldName = 'Label'
                settings.fieldName = str.format("format( '%%1%%2',  format_number(Label, 0), ' %s')" % labelSuffix)
                settings.isExpression = True
            settings.formatNumbers = True
            settings.decimals = 0
            settings.placement = QgsPalLayerSettings.Line
            labeling = QgsVectorLayerSimpleLabeling(settings)
            layer.setLabeling(labeling)
            layer.setLabelsEnabled(True) 
Example 30
Project: bssrdf-estimate   Author: tatsy   File: console_widget.py    MIT License 5 votes vote down vote up
def __init__(self, parent=None):
        super(ConsoleWidget, self).__init__(parent)

        self.textEdit = QTextEdit()
        self.textEdit.setFont(QFont('Consolas'))
        self.clearButton = QPushButton()
        self.clearButton.setText('Clear')

        self.vboxLayout = QVBoxLayout()
        self.vboxLayout.addWidget(self.textEdit)
        self.vboxLayout.addWidget(self.clearButton)
        self.setLayout(self.vboxLayout)

        self.clearButton.clicked.connect(self.clearConsoleTexts) 
Example 31
Project: Python-GUI   Author: arpitj07   File: New.py    MIT License 5 votes vote down vote up
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(100, 40, 201, 81))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")

        
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setGeometry(QtCore.QRect(150, 190, 111, 28))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setGeometry(QtCore.QRect(100, 140, 201, 22))
        self.lineEdit.setObjectName("lineEdit")

        
        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
Example 32
Project: Python-GUI   Author: arpitj07   File: Project.py    MIT License 5 votes vote down vote up
def combo2(self):
        myteam=sqlite3.connect("TEAM.db")
        cu= myteam.cursor()
        
        team = self.eval_screen.SelectTeam.currentText()
        cu.execute("SELECT PlAYERS from team WHERE NAMES='"+team+"';")
        player= cu.fetchall()
        self.eval_screen.PlayerList.clear()
        for i in range(len(player)):
            item= QtWidgets.QListWidgetItem(player[i][0])
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            item.setFont(font)
            item.setBackground(QtGui.QColor('#ffff99'))
            self.eval_screen.PlayerList.addItem(item)
        
        cu.execute("SELECT SCORES from team WHERE NAMES='"+team+"';")
        score=cu.fetchall()
        self.teamscore=[]
        for i in range(len(score)):
            self.teamscore.append(score[i][0])
    
        self.eval_screen.ScoreList.clear()
        for i in range(len(score)):
            items= QtWidgets.QListWidgetItem(str(score[i][0]))
            font = QtGui.QFont()
            font.setBold(True)
            font.setWeight(75)
            items.setFont(font)
            items.setBackground(QtGui.QColor('#fdc086'))
            self.eval_screen.ScoreList.addItem(items) 
Example 33
Project: Linalfred   Author: PeterHo   File: maineditbox.py    MIT License 5 votes vote down vote up
def setEditBoxFont(self):
        font = QFont()
        font.setPointSize(self.dlg.theme.editBoxFontSize)
        self.setFont(font) 
Example 34
Project: pyweed   Author: iris-edu   File: WaveformDialog.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, value):
        super(KeepIndicatorTableWidgetItem, self).__init__()
        self.setKeep(value)
        # Use a large font size for the checkboxes
        font = QtGui.QFont()
        font.setPointSize(self.fontSize)
        self.setFont(font) 
Example 35
Project: cct   Author: awacha   File: scripteditor.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        QtGui.QSyntaxHighlighter.__init__(self, *args, **kwargs)
        self.keywordformat = QtGui.QTextCharFormat()
        self.keywordformat.setFontWeight(QtGui.QFont.Bold)
        self.keywordformat.setForeground(QtCore.Qt.darkMagenta)
        self.keywords_re = [re.compile(r'\b' + c.name + r'\b') for c in Command.allcommands()]
        self.commentformat = QtGui.QTextCharFormat()
        self.commentformat.setForeground(QtCore.Qt.lightGray)
        self.comment_re = re.compile('#.*$')
        self.labelformat = QtGui.QTextCharFormat()
        self.labelformat.setForeground(QtCore.Qt.blue)
        self.label_re = re.compile(r'^\s*\@.*$') 
Example 36
Project: cct   Author: awacha   File: motorlist.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def data(self, index: QtCore.QModelIndex, role=None):
        motorname = sorted(self.credo.motors.keys())[index.row()]
        motor = self.credo.motors[motorname]
        assert isinstance(motor, Motor)
        if role == QtCore.Qt.DisplayRole:
            if index.column() == 0:
                return motorname
            elif index.column() == 1:
                return '{:.4f}'.format(motor.get_variable('softleft'))
            elif index.column() == 2:
                return '{:.4f}'.format(motor.get_variable('softright'))
            elif index.column() == 3:
                return '{:.4f}'.format(motor.get_variable('actualposition'))
            elif index.column() == 4:
                return '{:.4f}'.format(motor.get_variable('actualspeed'))
            elif index.column() == 5:
                return ''
            elif index.column() == 6:
                return ''
            elif index.column() == 7:
                return str(motor.get_variable('load'))
            elif index.column() == 8:
                return ', '.join(motor.decode_error_flags())
            else:
                return None
        elif role == QtCore.Qt.CheckStateRole:
            if index.column() == 5:
                return [QtCore.Qt.Unchecked, QtCore.Qt.Checked][motor.get_variable('leftswitchstatus')]
            elif index.column() == 6:
                return [QtCore.Qt.Unchecked, QtCore.Qt.Checked][motor.get_variable('rightswitchstatus')]
            else:
                return None
        elif role == QtCore.Qt.FontRole:
            if index.column() == 3:
                font = QtGui.QFont()
                font.setBold(True)
                return font
            else:
                return None
        else:
            return None 
Example 37
Project: pyaudiorestoration   Author: HENDRIX-ZT2   File: widgets.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, ):
		QtWidgets.QLabel.__init__(self, )
		self.def_text = "\n          - Note\n        -.- Hz\n-:--:--:--- h:m:s:ms"
		myFont2=QtGui.QFont("Monospace")
		myFont2.setStyleHint(QtGui.QFont.TypeWriter)
		self.setFont(myFont2) 
Example 38
Project: tf-pose   Author: SrikanthVelpuri   File: FlowchartTemplate_pyqt5.py    Apache License 2.0 5 votes vote down vote up
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(529, 329)
        self.selInfoWidget = QtWidgets.QWidget(Form)
        self.selInfoWidget.setGeometry(QtCore.QRect(260, 10, 264, 222))
        self.selInfoWidget.setObjectName("selInfoWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.selInfoWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.selDescLabel = QtWidgets.QLabel(self.selInfoWidget)
        self.selDescLabel.setText("")
        self.selDescLabel.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
        self.selDescLabel.setWordWrap(True)
        self.selDescLabel.setObjectName("selDescLabel")
        self.gridLayout.addWidget(self.selDescLabel, 0, 0, 1, 1)
        self.selNameLabel = QtWidgets.QLabel(self.selInfoWidget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.selNameLabel.setFont(font)
        self.selNameLabel.setText("")
        self.selNameLabel.setObjectName("selNameLabel")
        self.gridLayout.addWidget(self.selNameLabel, 0, 1, 1, 1)
        self.selectedTree = DataTreeWidget(self.selInfoWidget)
        self.selectedTree.setObjectName("selectedTree")
        self.selectedTree.headerItem().setText(0, "1")
        self.gridLayout.addWidget(self.selectedTree, 1, 0, 1, 2)
        self.hoverText = QtWidgets.QTextEdit(Form)
        self.hoverText.setGeometry(QtCore.QRect(0, 240, 521, 81))
        self.hoverText.setObjectName("hoverText")
        self.view = FlowchartGraphicsView(Form)
        self.view.setGeometry(QtCore.QRect(0, 0, 256, 192))
        self.view.setObjectName("view")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
Example 39
Project: MeiTingTrunk   Author: Xunius   File: _MainFrame.py    GNU General Public License v3.0 5 votes vote down vote up
def createScratchTab(self):

        scroll=QtWidgets.QScrollArea(self)
        scroll.setWidgetResizable(True)
        frame=QtWidgets.QFrame()
        v_layout=QtWidgets.QVBoxLayout()

        self.scratchpad_textedit=QtWidgets.QTextEdit(self)
        self.scratchpad_textedit.setFont(self.settings.value(
            '/display/fonts/scratch_pad',QFont))
        self.scratchpad_textedit.setSizePolicy(getXExpandYExpandSizePolicy())

        v_layout.addWidget(self.scratchpad_textedit)
        frame.setLayout(v_layout)
        scroll.setWidget(frame)

        return scroll 
Example 40
Project: MeiTingTrunk   Author: Xunius   File: _MainFrame.py    GNU General Public License v3.0 5 votes vote down vote up
def createBiBTab(self):

        frame=QtWidgets.QWidget()
        scroll=QtWidgets.QScrollArea(self)
        scroll.setWidgetResizable(True)
        scroll.setWidget(frame)
        v_layout=QtWidgets.QVBoxLayout()

        self.copy_bib_button=QtWidgets.QToolButton(self)
        self.copy_bib_button.setText('Copy')
        self.copy_bib_button.setIcon(QIcon.fromTheme('edit-copy',
                self.style().standardIcon(QStyle.SP_FileDialogDetailedView)))
        self.copy_bib_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)

        h_layout=QtWidgets.QHBoxLayout()
        h_layout.addWidget(self.copy_bib_button)
        h_layout.addStretch()

        self.bib_textedit=QtWidgets.QTextEdit(self)
        self.bib_textedit.setReadOnly(True)
        self.bib_textedit.setFont(self.settings.value('/display/fonts/bibtex',QFont))
        v_layout.addLayout(h_layout)
        v_layout.addWidget(self.bib_textedit)
        frame.setLayout(v_layout)
        self.copy_bib_button.clicked.connect(self.copyBibButtonClicked)

        return scroll 
Example 41
Project: SpriteMator   Author: rafaelvasco   File: application.py    Apache License 2.0 5 votes vote down vote up
def _load_assets():

        # Fonts #

        QFontDatabase.addApplicationFont(":/fonts/font_nokia")
        QFontDatabase.addApplicationFont(":/fonts/font_flx")

        default_font = QFont("Nokia Cellphone FC")
        default_font.setPointSize(12)

        small_font = QFont("flxpixl")
        small_font.setPointSize(12)

        ResourcesCache.register_resource("BigFont", default_font)
        ResourcesCache.register_resource("SmallFont", small_font)

        # Pixmaps #

        checker_tile_light = utils.generate_checkerboard_tile(8, QColor(238, 238, 238),
                                                              QColor(255, 255, 255))
        checker_tile_dark = utils.generate_checkerboard_tile(8, QColor(59, 59, 59),
                                                             QColor(63, 63, 63))

        ResourcesCache.register_resource("CheckerTileLight", checker_tile_light)
        ResourcesCache.register_resource("CheckerTileDark", checker_tile_dark)

        tool_cursor_1 = QPixmap(':/images/tool_cursor_1')

        ResourcesCache.register_resource('ToolCursor1', tool_cursor_1) 
Example 42
Project: eddy   Author: obdasystems   File: qt.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, family, size=12, weight=-1, **kwargs):
        """
        Contruct a new Font instance using the given parameters.
        :type family: str
        :type size: float
        :type weight: float
        """
        if not _MACOS:
            size = int(round(size * 0.75))
        super().__init__(family, size, weight)
        self.setBold(kwargs.get('bold', False))
        self.setItalic(kwargs.get('italic', False))
        self.setCapitalization(kwargs.get('capitalization', QtGui.QFont.MixedCase))
        self.setStyleHint(kwargs.get('style', QtGui.QFont.AnyStyle)) 
Example 43
Project: eddy   Author: obdasystems   File: pdf.py    GNU General Public License v3.0 5 votes vote down vote up
def append_row_and_column_to_table(self,iri,prefix,brush,bold=None):

        item_iri = QtWidgets.QTableWidgetItem()
        item_iri.setText(iri)

        if brush is not None:
            item_iri.setBackground(brush)

        item_prefix = QtWidgets.QTableWidgetItem()
        item_prefix.setText(prefix)

        if bold:
            font_iri = QtGui.QFont(item_iri.text())
            font_iri.setBold(True)
            item_iri.setFont(font_iri)

            font_prefix = QtGui.QFont(item_prefix.text())
            font_prefix.setBold(True)
            item_prefix.setFont(font_prefix)

        if brush is not None:
            item_prefix.setBackground(brush)

        self.table.setItem(self.table.rowCount() - 1, 0, item_iri)
        self.table.setItem(self.table.rowCount() - 1, 1, item_prefix)

        self.table.setRowCount(self.table.rowCount() + 1) 
Example 44
Project: data-structure   Author: yunowo   File: main_stats_tab.py    GNU General Public License v3.0 5 votes vote down vote up
def show_bar_chart(self):
        t20 = list(reversed(list(islice(self.d.items(), 20))))
        bs = QBarSet("")
        bs.append([c[1] for c in t20])
        hbs = QHorizontalBarSeries()
        hbs.append(bs)
        hbs.setBarWidth(0.6)
        hbs.setLabelsVisible(True)
        hbs.setLabelsPosition(QHorizontalBarSeries.LabelsInsideEnd)

        font = QFont()
        font.setFamily('Segoe UI')
        font.setPixelSize(10)
        x = QValueAxis()
        y = QBarCategoryAxis()
        y.append([c[0] for c in t20])
        x.setGridLineVisible(False)
        y.setGridLineVisible(False)
        x.setLabelsFont(font)
        y.setLabelsFont(font)

        c = QChart()
        c.addSeries(hbs)
        c.setAxisY(y, hbs)
        c.setAxisX(x, hbs)
        x.applyNiceNumbers()
        c.setAnimationOptions(QChart.SeriesAnimations)
        c.setBackgroundRoundness(0)
        c.legend().hide()
        c.layout().setContentsMargins(0, 0, 0, 0)

        if self.cv is not None:
            self.w.bar_chart_container.removeWidget(self.cv)
        self.cv = QChartView(c)
        self.cv.setRenderHint(QPainter.Antialiasing)
        self.w.bar_chart_container.addWidget(self.cv) 
Example 45
Project: data-structure   Author: yunowo   File: common.py    GNU General Public License v3.0 5 votes vote down vote up
def font():
    f = QtGui.QFont()
    f.setFamily('微软雅黑')
    return f 
Example 46
Project: pdash   Author: CPChain   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def init_font(application):
    # load fonts
    utils.load_fonts(abs_path('fonts'))
    font_name = "Microsoft Sans Serif" if app.is_windows() else "SF UI Display"
    font = QFont(font_name)
    application.setFont(font) 
Example 47
Project: dunya-desktop   Author: MTG   File: general_design.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_status_bar(self):
        self.statusbar.setMinimumSize(QtCore.QSize(0, 18))
        font = QFont()
        font.setPointSize(9)
        self.statusbar.setFont(font) 
Example 48
Project: dunya-desktop   Author: MTG   File: table.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_font(self):
        """Sets the font of the table"""
        font = QFont()
        font.setPointSize(FONT_SIZE)
        self.setFont(font) 
Example 49
Project: dunya-desktop   Author: MTG   File: tabwidget.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_font(self):
        font = QFont()
        font.setPointSize(10)
        self.setFont(font) 
Example 50
Project: dunya-desktop   Author: MTG   File: dockwidget.py    GNU General Public License v3.0 5 votes vote down vote up
def _set_label_downloaded(self):
        """Sets the label 'Downloaded'."""
        font = QFont()
        font.setFamily("Garuda")
        self.label_downloaded.setFont(font)
        self.label_downloaded.setIndent(15)