當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QFont方法代碼示例

本文整理匯總了Python中qtpy.QtGui.QFont方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QFont方法的具體用法?Python QtGui.QFont怎麽用?Python QtGui.QFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在qtpy.QtGui的用法示例。


在下文中一共展示了QtGui.QFont方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_plot_item

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def create_plot_item(self, name):
        """生成PlotItem對象"""
        vb = CustomViewBox()
        plotItem = pg.PlotItem(viewBox = vb, name=name ,axisItems={'bottom': self.axisTime})
        plotItem.setMenuEnabled(False)
        plotItem.setClipToView(True)
        plotItem.hideAxis('left')
        plotItem.showAxis('right')
        plotItem.setDownsampling(mode='peak')
        plotItem.setRange(xRange = (0,1),yRange = (0,1))
        plotItem.getAxis('right').setWidth(60)
        plotItem.getAxis('right').setStyle(tickFont = QtGui.QFont("Roman times",10,QtGui.QFont.Bold))
        plotItem.getAxis('right').setPen(color=(255, 255, 255, 255), width=0.8)
        plotItem.showGrid(True, True)
        plotItem.hideButtons()
        return plotItem

    # ---------------------------------------------------------------------- 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:20,代碼來源:uiKLine.py

示例2: data_internal

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def data_internal(self, index, record, role):
        result = None
        if role == Qt.DisplayRole:
            if index.column() == self.columnCount(INVALID_INDEX) - 1:
                result = record._cutelog
            else:
                column = self.table_header[index.column()]
                if column.name == 'asctime':
                    result = record.asctime
        elif role == Qt.SizeHintRole:
            result = QSize(1, CONFIG.logger_row_height)
        elif role == Qt.FontRole:
            result = QFont(CONFIG.logger_table_font, CONFIG.logger_table_font_size)
        elif role == Qt.ForegroundRole:
            if not self.dark_theme:
                result = QColor(Qt.black)
            else:
                result = QColor(Qt.white)
        elif role == Qt.BackgroundRole:
            if not self.dark_theme:
                color = QColor(Qt.lightGray)
            else:
                color = QColor(Qt.darkGray)
            result = QBrush(color, Qt.BDiagPattern)
        return result 
開發者ID:busimus,項目名稱:cutelog,代碼行數:27,代碼來源:logger_tab.py

示例3: get_preview_items

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def get_preview_items(self, level):
        previewItem = QTableWidgetItem("Log message")
        previewItem.setBackground(QBrush(level.bg, Qt.SolidPattern))
        previewItem.setForeground(QBrush(level.fg, Qt.SolidPattern))
        previewItemDark = QTableWidgetItem("Log message")
        previewItemDark.setBackground(QBrush(level.bgDark, Qt.SolidPattern))
        previewItemDark.setForeground(QBrush(level.fgDark, Qt.SolidPattern))
        font = QFont(CONFIG.logger_table_font, CONFIG.logger_table_font_size)
        fontDark = QFont(font)
        if 'bold' in level.styles:
            font.setBold(True)
        if 'italic' in level.styles:
            font.setItalic(True)
        if 'underline' in level.styles:
            font.setUnderline(True)
        if 'bold' in level.stylesDark:
            fontDark.setBold(True)
        if 'italic' in level.stylesDark:
            fontDark.setItalic(True)
        if 'underline' in level.stylesDark:
            fontDark.setUnderline(True)
        previewItem.setFont(font)
        previewItemDark.setFont(fontDark)
        return previewItem, previewItemDark 
開發者ID:busimus,項目名稱:cutelog,代碼行數:26,代碼來源:levels_preset_dialog.py

示例4: __init__

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def __init__(self, value='', parent=None, get_pos=None):
        super().__init__(value, parent=parent)
        self.fm = QFontMetrics(QFont("", 0))
        self.setObjectName('slice_label')
        self.min_width = 30
        self.max_width = 200
        self.setCursor(Qt.IBeamCursor)
        self.setValidator(QDoubleValidator())
        self.textChanged.connect(self._on_text_changed)
        self._on_text_changed(value)

        self.get_pos = get_pos
        if parent is not None:
            self.min_width = 50
            self.slider = parent.slider
            self.setAlignment(Qt.AlignCenter) 
開發者ID:napari,項目名稱:napari,代碼行數:18,代碼來源:qt_range_slider_popup.py

示例5: _resize_axis_labels

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def _resize_axis_labels(self):
        """When any of the labels get updated, this method updates all label
        widths to the width of the longest label. This keeps the sliders
        left-aligned and allows the full label to be visible at all times,
        with minimal space, without setting stretch on the layout.
        """
        fm = QFontMetrics(QFont("", 0))
        labels = self.findChildren(QLineEdit, 'axis_label')
        newwidth = max([fm.boundingRect(lab.text()).width() for lab in labels])

        if any(self._displayed_sliders):
            # set maximum width to no more than 20% of slider width
            maxwidth = self.slider_widgets[0].width() * 0.2
            newwidth = min([newwidth, maxwidth])
        for labl in labels:
            labl.setFixedWidth(newwidth + 10) 
開發者ID:napari,項目名稱:napari,代碼行數:18,代碼來源:qt_dims.py

示例6: _resize_slice_labels

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def _resize_slice_labels(self):
        """When the size of any dimension changes, we want to resize all of the
        slice labels to width of the longest label, to keep all the sliders
        right aligned.  The width is determined by the number of digits in the
        largest dimensions, plus a little padding.
        """
        width = 0
        for ax, maxi in enumerate(self.dims.max_indices):
            if self._displayed_sliders[ax]:
                length = len(str(int(maxi)))
                if length > width:
                    width = length
        # gui width of a string of length `width`
        fm = QFontMetrics(QFont("", 0))
        width = fm.boundingRect("8" * width).width()
        for labl in self.findChildren(QWidget, 'slice_label'):
            labl.setFixedWidth(width + 6) 
開發者ID:napari,項目名稱:napari,代碼行數:19,代碼來源:qt_dims.py

示例7: get_font

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def get_font(family, fallback=None):
    """Return a font of the requested family, using fallback as alternative.

    If a fallback is provided, it is used in case the requested family isn't
    found.  If no fallback is given, no alternative is chosen and Qt's internal
    algorithms may automatically choose a fallback font.

    Parameters
    ----------
    family : str
      A font name.
    fallback : str
      A font name.

    Returns
    -------
    font : QFont object
    """
    font = QtGui.QFont(family)
    # Check whether we got what we wanted using QFontInfo, since exactMatch()
    # is overly strict and returns false in too many cases.
    font_info = QtGui.QFontInfo(font)
    if fallback is not None and font_info.family() != family:
        font = QtGui.QFont(fallback)
    return font 
開發者ID:jupyter,項目名稱:qtconsole,代碼行數:27,代碼來源:util.py

示例8: reset_font

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def reset_font(self):
        """ Sets the font to the default fixed-width font for this platform.
        """
        if sys.platform == 'win32':
            # Consolas ships with Vista/Win7, fallback to Courier if needed
            fallback = 'Courier'
        elif sys.platform == 'darwin':
            # OSX always has Monaco
            fallback = 'Monaco'
        else:
            # Monospace should always exist
            fallback = 'Monospace'
        font = get_font(self.font_family, fallback)
        if self.font_size:
            font.setPointSize(self.font_size)
        else:
            font.setPointSize(QtWidgets.QApplication.instance().font().pointSize())
        font.setStyleHint(QtGui.QFont.TypeWriter)
        self._set_font(font) 
開發者ID:jupyter,項目名稱:qtconsole,代碼行數:21,代碼來源:console_widget.py

示例9: __init__

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def __init__(self, xdict, *args, **kwargs):
        pg.AxisItem.__init__(self, *args, **kwargs)
        self.minVal = 0 
        self.maxVal = 0
        # 序列 <= > 時間
        self.xdict  = OrderedDict()
        self.xdict.update(xdict)
        # 時間 <=> 序列
        self.tdict  = OrderedDict([(v,k) for k,v in xdict.items()])
        self.x_values = np.asarray(xdict.keys())
        self.x_strings = list(xdict.values())
        self.setPen(color=(255, 255, 255, 255), width=0.8)
        self.setStyle(tickFont = QtGui.QFont("Roman times",10,QtGui.QFont.Bold),autoExpandTextSpace=True) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:15,代碼來源:uiKLine.py

示例10: convertMplWeightToQtWeight

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def convertMplWeightToQtWeight(self, weight: str) -> int:
        """ convert a font weight string to a weight enumeration of Qt """
        weight_dict = {'normal': QtGui.QFont.Normal, 'bold': QtGui.QFont.Bold, 'heavy': QtGui.QFont.ExtraBold,
                       'light': QtGui.QFont.Light, 'ultrabold': QtGui.QFont.Black, 'ultralight': QtGui.QFont.ExtraLight}
        if weight in weight_dict:
            return weight_dict[weight]
        return weight_dict["normal"] 
開發者ID:rgerum,項目名稱:pylustrator,代碼行數:9,代碼來源:QComplexWidgets.py

示例11: convertQtWeightToMplWeight

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def convertQtWeightToMplWeight(self, weight: int) -> str:
        """ convert a Qt weight value to a string for use in matmplotlib """
        weight_dict = {QtGui.QFont.Normal: 'normal', QtGui.QFont.Bold: 'bold', QtGui.QFont.ExtraBold: 'heavy',
                       QtGui.QFont.Light: 'light', QtGui.QFont.Black: 'ultrabold', QtGui.QFont.ExtraLight: 'ultralight'}
        if weight in weight_dict:
            return weight_dict[weight]
        return "normal" 
開發者ID:rgerum,項目名稱:pylustrator,代碼行數:9,代碼來源:QComplexWidgets.py

示例12: selectFont

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def selectFont(self):
        """ open a font select dialog """
        font0 = QtGui.QFont()
        font0.setFamily(self.target.get_fontname())
        font0.setWeight(self.convertMplWeightToQtWeight(self.target.get_weight()))
        font0.setItalic(self.target.get_style() == "italic")
        font0.setPointSizeF(self.target.get_fontsize())
        font, x = QtWidgets.QFontDialog.getFont(font0, self)

        for element in self.target_list:
            element.set_fontname(font.family())
            element.figure.change_tracker.addChange(element, ".set_fontname(\"%s\")" % (element.get_fontname(),))

            if font.weight() != font0.weight():
                weight = self.convertQtWeightToMplWeight(font.weight())
                element.set_weight(weight)
                element.figure.change_tracker.addChange(element, ".set_weight(\"%s\")" % (weight,))

            if font.pointSizeF() != font0.pointSizeF():
                element.set_fontsize(font.pointSizeF())
                element.figure.change_tracker.addChange(element, ".set_fontsize(%f)" % (font.pointSizeF(),))

            if font.italic() != font0.italic():
                style = "italic" if font.italic() else "normal"
                element.set_style(style)
                element.figure.change_tracker.addChange(element, ".set_style(\"%s\")" % (style,))

        self.target.figure.canvas.draw()
        self.setTarget(self.target_list) 
開發者ID:rgerum,項目名稱:pylustrator,代碼行數:31,代碼來源:QComplexWidgets.py

示例13: __init__

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def __init__(self, parent=None):
        """Constructor."""
        QAbstractItemModel.__init__(self, parent)
        self.abbreviator = Abbreviator()
        self.is_dark_interface = False
        self.testresults = []
        try:
            self.monospace_font = parent.window().editor.get_plugin_font()
        except AttributeError:  # If run standalone for testing
            self.monospace_font = QFont("Courier New")
            self.monospace_font.setPointSize(10) 
開發者ID:spyder-ide,項目名稱:spyder-unittest,代碼行數:13,代碼來源:datatree.py

示例14: reset

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def reset(self):
        tlvcols = 4
        tlvcolsnames = ['S', 'Pattern', 'P', 'Comment']
        v = self.patternTable
        v.setColumnCount(tlvcols)
        lh = v.horizontalHeader()
        lv = v.verticalHeader()
        h = tlvcolsnames
        n = len(h)
        for i in range(n):
            hi = QTableWidgetItem(h[i])
            v.setHorizontalHeaderItem(i, hi)
        for profkey in self._profiles:
            prof = self._profiles[profkey]
            for k in prof:
                pentry = prof[k]
                v.setRowCount(v.rowCount() + 1)
                r = v.rowCount() - 1
                it1 = QTableWidgetItem(self.IC(QW.I_EMPTY), '')
                it2 = QTableWidgetItem(k)
                it2.setFont(QFont("Courier"))
                it3 = QTableWidgetItem(profkey)
                it4 = QTableWidgetItem(pentry[2])
                v.setItem(r, 0, it1)
                v.setItem(r, 1, it2)
                v.setItem(r, 2, it3)
                v.setItem(r, 3, it4)
        self.patternTable.resizeColumnsToContents()
        self.patternTable.resizeRowsToContents()
        plist = []
        for i in range(len(plist)):
            v.resizeColumnToContents(i)
        for i in range(v.rowCount()):
            v.resizeRowToContents(i)
        self._initialized = True 
開發者ID:pyCGNS,項目名稱:pyCGNS,代碼行數:37,代碼來源:wpattern.py

示例15: addPathEntry

# 需要導入模塊: from qtpy import QtGui [as 別名]
# 或者: from qtpy.QtGui import QFont [as 別名]
def addPathEntry(self, parent, path, state, top=False):
        it = QTreeWidgetItem(parent, (path,))
        ft = QFont(OCTXT._Table_Font)
        if top:
            ft.setBold(True)
        it.setFont(0, ft)
        if state == CGM.CHECK_FAIL:
            it.setIcon(0, self.IC(QW.I_C_SFL))
        if state == CGM.CHECK_WARN:
            it.setIcon(0, self.IC(QW.I_C_SWR))
        return it 
開發者ID:pyCGNS,項目名稱:pyCGNS,代碼行數:13,代碼來源:wdiag.py


注:本文中的qtpy.QtGui.QFont方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。