当前位置: 首页>>代码示例>>Python>>正文


Python QFont.setStyleHint方法代码示例

本文整理汇总了Python中PySide.QtGui.QFont.setStyleHint方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setStyleHint方法的具体用法?Python QFont.setStyleHint怎么用?Python QFont.setStyleHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QFont的用法示例。


在下文中一共展示了QFont.setStyleHint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setStyleHint [as 别名]
 def __init__(self, repo, selected_items, parent=None):
     super(CommitDialog, self).__init__(parent=parent)
     self.repo = repo
     self.dialog_buttons.button(QDialogButtonBox.Ok).setEnabled(False)
     self.selected_items = selected_items
     if len(selected_items) == 1 and isinstance(selected_items[0],
             WorkspaceDirectory):
         self.root_dir = selected_items[0]
     else:
         self.root_dir = None
     fixed_font = QFont('Courier', self.message_text.font().pointSize())
     fixed_font.setStyleHint(QFont.Monospace)
     self.message_text.setFont(fixed_font)
     self.text_pos_label.setFont(fixed_font)
     with busy_cursor():
         self.staged_changes_model = StagedChangesModel(repo, self.root_dir,
             parent=self)
         self.local_changes_model = LocalChangesModel(repo.workspace,
             parent=self)
         self.local_changes_model.file_source = lambda: tuple(deep_item
             for selected_item in selected_items
             for deep_item in deep_file_list(selected_item)
             if exclude_unmodified(deep_item) and exclude_ignored(deep_item))
         if self.root_dir:
             self.staged_changes_button.setChecked(True)
             self.show_staged_changes()
         else:
             self.local_changes_button.setChecked(True)
             self.show_local_changes()
         if self.repo.head_ref:
             (self.last_commit,) = self.repo.log(max_commits=1)
         else:
             self.last_commit = None
             self.action_reuse_last_msg.setEnabled(False)
             self.action_reuse_log_msg.setEnabled(False)
             self.amend_checkbox.setEnabled(False)
     self.staged_changes_button.clicked.connect(self.show_staged_changes)
     self.local_changes_button.clicked.connect(self.show_local_changes)
     self.local_changes_model.dataChanged.connect(self.local_change_toggled)
     self.message_text.cursorPositionChanged.connect(self.text_pos_changed)
     self.message_text.textChanged.connect(self.message_text_changed)
     reuse_menu = QMenu()
     reuse_menu.addAction(self.action_reuse_last_msg)
     reuse_menu.addAction(self.action_reuse_log_msg)
     self.reuse_msg_button.setDefaultAction(self.action_reuse_last_msg)
     self.reuse_msg_button.setMenu(reuse_menu)
     self.action_reuse_last_msg.triggered.connect(self.reuse_last_message)
     self.action_reuse_log_msg.triggered.connect(self.select_old_message)
     self.amend_checkbox.toggled.connect(self.amend_toggled)
开发者ID:vstojkovic,项目名称:berk,代码行数:51,代码来源:commit.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setStyleHint [as 别名]
 def __init__(self):
     super(Layer, self).__init__()
     self.orientation = Quaternion()
     self.picked = None
     self.show = QCheckBox()
     self.show.setChecked(True)
     self.alpha_slider = QSlider(QtCore.Qt.Orientation.Horizontal)
     self.alpha_slider.setRange(0, 1024)
     self.alpha_slider.setValue(1024)
     self.alpha_number = QDoubleSpinBox()
     self.alpha_number.setDecimals(3)
     self.alpha_number.setSingleStep(0.01)
     self.alpha_number.setRange(0, 1)
     self.alpha_number.setValue(1)
     self.alpha_slider.valueChanged.connect(self._alphaSliderChanged)
     self.alpha_number.valueChanged.connect(self._alphaNumberChanged)
     self.move = QCheckBox()
     self.move.setChecked(True)
     self.quat = QLineEdit()
     font = QFont('monospace')
     font.setStyleHint(QFont.TypeWriter)
     self.quat.setFont(font)
     default_quat = '+0.000, +1.000, +0.000, +0.000'
     margins = self.quat.textMargins()
     self.quat.setFixedWidth(
         # HACK -------------------------------------------v
         QFontMetrics(self.quat.font()).width(default_quat + '  ') +
         margins.left() + margins.right()
     )
     self.quat.setInputMask('#0.000, #0.000, #0.000, #0.000')
     self.quat.setMaxLength(30)
     self.quat.setText(default_quat)
     self.quat.editingFinished.connect(self._orientationChanged)
     self.nbytes = QLabel()
     self.nbytes.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
     self.nbytes.setText('0')
     self.label = QLabel()
     self.label.setText('<empty>')
开发者ID:mkovacs,项目名称:sphaira,代码行数:40,代码来源:layer.py

示例3: StringHexTableModel

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setStyleHint [as 别名]
class StringHexTableModel(QAbstractTableModel):
    def __init__(self, width = 8):
        super(StringHexTableModel, self).__init__()
        self.width = width
        self.byte_data = ""
        self.start_address = 0
        self.set_data("i.MX toolkit \x02\x03 test" * 50, 0xfeedcafe)
        self.font = QFont("Monospace")
        self.font.setStyleHint(QFont.TypeWriter)

    def set_data(self, byte_data, start_address):
        """ Set model data, re-assign columns/rows, and signal a model reset """
        self.byte_data = byte_data
        self.start_address = start_address
        self.row_count = max(1, len(byte_data) / self.width)

        self.reset()

    def rowCount(self, parent):
        return self.row_count

    def columnCount(self, parent):
        # Hex, ASCII display columns with one spacer column
        return 2 * self.width + 1

    def data(self, index, role):
        value = None
        if role == Qt.DisplayRole:
            row = index.row()
            col = index.column()

            try:
                # Show ASCII value (if not printable, show ".") beside hex representation
                if col > self.width:
                    true_col = (col - self.width - 1)
                    value = self.byte_data[self.width * row + true_col]
                    if not (0x1F <= ord(value) <= 0x7F):
                        value = "."

                # Show hex representation
                elif col < self.width:
                    byte = self.byte_data[self.width * row + col]
                    value = "%02x" % ord(byte)

            except IndexError:
                pass

        elif role == Qt.FontRole:
            return self.font

        # All values should be centered.
        elif role == Qt.TextAlignmentRole:
            value = Qt.AlignCenter

        return value

    def headerData(self, section, orientation, role):
        """
        Show the header for the hex dump view.
        """
        value = None
        if role == Qt.DisplayRole:
            # Horizontal = column address within row
            if orientation == Qt.Horizontal:
                if section < self.width:
                    value = "%X" % section
                elif section > self.width:
                    value = "%X" % (section - self.width - 1)

            # Vertical = row address
            else:
                base_address = self.start_address + (section * self.width)
                upper_word = ((base_address & 0xFFFF0000) >> 16)
                lower_word = (base_address & 0x0000FFFF)

                value = "%04x %04x" % (upper_word, lower_word)

        # Header should be centered.
        elif role == Qt.TextAlignmentRole:
            value = Qt.AlignCenter

        return value
开发者ID:hbock,项目名称:pyatk,代码行数:84,代码来源:__main__.py

示例4: create_facets_font

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setStyleHint [as 别名]
def create_facets_font ( value ):
    """ Creates a FacetFont object from a string description.
    """
    global font_cache

    if isinstance( value, QFont ):
        return FacetsFont( value )

    # Replace any list of fonts by a single matching font:
    value = font_select( value )

    # Check to see if the font is already in the cache, and return it if it is:
    font = font_cache.get( value )
    if font is not None:
        return font

    point_size = None
    family     = ''
    style      = QFont.StyleNormal
    weight     = QFont.Normal
    underline  = False
    facename   = []

    for word in value.split():
        lword = word.lower()
        if font_families.has_key( lword ):
            f = QFont()
            f.setStyleHint( font_families[ lword ] )
            family = f.defaultFamily()
        elif font_styles.has_key( lword ):
            style = font_styles[ lword ]
        elif font_weights.has_key( lword ):
            weight = font_weights[ lword ]
        elif lword == 'underline':
            underline = True
        elif lword not in font_noise:
            if point_size is None:
                try:
                    point_size = int( lword )
                    continue
                except:
                    pass

            facename.append( word )

    if facename:
        family = ' '.join( facename )

    if family:
        font = FacetsFont( family )
    else:
        font = FacetsFont()

    font.setStyle( style )
    font.setWeight( weight )
    font.setUnderline( underline )

    if point_size is not None:
        font.setPointSize( point_size )

    font_cache[ value ] = font

    return font
开发者ID:davidmorrill,项目名称:facets,代码行数:65,代码来源:font_facet.py

示例5: ScriptSetVal

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setStyleHint [as 别名]
class ScriptSetVal(QMainWindow):
    def __init__(self, tabID, subWinHandle, parent=None):
        super(ScriptSetVal,  self).__init__(parent)
        self.tabID = tabID    
        self.subWinHandle = subWinHandle
        self.tableHandle  = subWinHandle.widget().centralWidget()
        self.initUI()
        self.initToolBar()
        self.initDocker()
        
    def initUI(self): 
        self.t = QTextEdit()
        self.initFont()
        self.setCentralWidget(self.t)
        self.setGeometry(QRect(200, 200, 410, 610))
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.show()
    
    def initToolBar(self):
        self.scriptbar    = QToolBar('plot options') 
        self.addToolBar( Qt.BottomToolBarArea , self.scriptbar)
        scriptAction = QAction('set script', self)
        self.scriptbar.addAction(scriptAction)
        scriptAction.triggered.connect(self.RelectRng)

    def initFont(self):
        self.tabStop = 4
        self.font = QFont('Courier')
        self.metrics = QFontMetrics(self.font)
        self.t.setTabStopWidth(self.tabStop * self.metrics.width(' '));
        self.font.setStyleHint(QFont.Monospace);
        self.font.setFixedPitch(True);
        self.font.setPointSize(12)
        self.p = self.t.palette()
        self.p.setColor(QPalette.Base, QColor(0, 0, 0))
        self.p.setColor(QPalette.Text, QColor(255, 255, 255))
        self.t.setPalette(self.p)
        self.t.setFont(self.font)
        self.highlighter = Highlighter(self.t.document())

    def initDocker(self):
        self.elog = QTextEdit()
        self.elogDockWidget = QDockWidget("  ::  error log ::", self)
        self.elogDockWidget.setFeatures(QDockWidget.DockWidgetMovable)
        self.elogDockWidget.setAllowedAreas(Qt.TopDockWidgetArea and Qt.BottomDockWidgetArea)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.elogDockWidget)
        self.elogDockWidget.setWidget(self.elog)
        self.p = self.elog.palette()
        self.p.setColor(QPalette.Base, QColor(0, 0, 0))
        self.p.setColor(QPalette.Text, QColor(255, 0, 0))
        self.elog.setPalette(self.p)
        self.elog.setReadOnly(True)

          

    def RelectRng(self):
        try:
            self.selectAry = []
            if len(self.tableHandle.selectedRanges()) != 0:
                for i in range( len(self.tableHandle.selectedRanges())):
                    self.leftCol  = self.tableHandle.selectedRanges()[i].leftColumn()
                    self.colCount = self.tableHandle.selectedRanges()[i].columnCount()
                    for currentCol in range( self.leftCol, self.leftCol + self.colCount ):
                        self.selectAry.append( currentCol )
                self.leftCol  = self.tableHandle.selectedRanges()[0].leftColumn()
                self.colCount = self.tableHandle.selectedRanges()[0].columnCount()
                self.topRow   = self.tableHandle.selectedRanges()[0].topRow()
                self.rowCount = self.tableHandle.selectedRanges()[0].rowCount()
                
                rows = []
                cols = []
                for i in range(self.topRow,  self.topRow  + self.rowCount, 1):
                    rows.append(i)
                for i in range(self.leftCol, self.leftCol + self.colCount, 1):
                    cols.append(i)

                try:
                    exec(self.t.toPlainText())
                except Exception, e:
                    self.elog.moveCursor(QTextCursor.End)
                    self.elog.textCursor().insertHtml('<span style="color:#FF0000">Error: '+str(e)+'</span><br>')
                    

                    print str(e)
            else:
开发者ID:s910324,项目名称:Sloth,代码行数:87,代码来源:NightlyBuild-0613-plot_cluster_fixed.py


注:本文中的PySide.QtGui.QFont.setStyleHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。