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


Python QFont.setFixedPitch方法代码示例

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


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

示例1: EditorWindow

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFixedPitch [as 别名]

#.........这里部分代码省略.........
        #self.tixi.close()
        #self.tixi.cleanup() 

    '''
    set and connect the search buttons
    '''
    def setupButtonMenu(self):
        self.button1         = QPushButton("previous" )
        self.button2         = QPushButton("next" )
        self.label1          = QLabel("font")
        self.fontsizeSpinBox = QSpinBox()
        
        self.button1.hide()
        self.button2.hide()
        self.label1.hide()
        self.fontsizeSpinBox.hide()

        self.button1.clicked.connect(self.fire_search_backward)
        self.button2.clicked.connect(self.fire_search_foreward)
         
        self.fontsizeSpinBox.setRange(4, 30)
        self.fontsizeSpinBox.setSingleStep(1)
        self.fontsizeSpinBox.setSuffix('pt')
        self.fontsizeSpinBox.setValue(10)        
        self.fontsizeSpinBox.valueChanged.connect(self.setfontsize)         
    
    def setfontsize(self, value):
        self.font.setPointSize(value)
        self.editor.setFont(self.font)
                
    def setupEditor(self):
        self.font = QFont()
        self.font.setFamily('Courier')
        self.font.setFixedPitch(True)
        self.font.setPointSize(10)
        
        self.editor = EditorCodeCompletion(Config().path_code_completion_dict)       
        self.editor.setFont(self.font)
        self.editor.setTabStopWidth(20)
        self.editor.setAcceptRichText(False)
        self.editor.setLineWrapMode(QTextEdit.NoWrap)
        self.editor.textChanged.connect(self.validate)
        
        self.highlighter = Highlighter(self.editor.document())
    
    def setupNumbar(self):
        self.number_bar = NumberBar()
        self.number_bar.setTextEdit(self.getStates())
        self.editor.cursorPositionChanged.connect(self.fireUpdateNumbar)        
        self.connect(self.editor.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.fireUpdateNumbar)  
        #self.editor.verticalScrollBar.valueChanged.connect(self.fireUpdateNumbar)

    def setupStatusbar(self):
        self.lineNumber = -1
        self.colNumber = -1
        self.m_statusRight = QLabel("row: " + str(self.lineNumber) + ", col:"  + str(self.colNumber), self)
        self.statusBar().addPermanentWidget(self.m_statusRight, 0) 

    def setupSearchBox(self):
        self.searchbox = SearchField() 
        self.searchbox.hide()     
        
    def setupMenubar(self):
        commentAction = QAction('Comment', self)
        commentAction.setShortcut('Ctrl+K')
        commentAction.setStatusTip('Comment Block')
开发者ID:frankfx,项目名称:master_thesis,代码行数:70,代码来源:editor_xml.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFixedPitch [as 别名]
    def __init__(self, parent=None, filePath=''):
        """Default class constructor."""
        super(MDISubWindow_TextEdit, self).__init__(parent)

        print(filePath)
        self.filePath = filePath
        self.fileName = os.path.basename(os.path.abspath(filePath))
        self.fileExt = os.path.splitext(self.fileName)[1]

        if not filePath:
            self.setWindowTitle('Untitled[*]')
            parent.setWindowIcon(QIcon(gIconDir + os.sep + 'new.png'))
        else:
            f = open(filePath, 'r')
            txt = f.read()
            f.close()
            self.setText(txt)

            self.setWindowTitle('%s[*]' % self.fileName)

            # TODO: This is changing all the subwindows icons. We want individual icons based on filetype...?
            if self.fileExt in ('.py', '.pyw'):
                parent.setWindowIcon(QIcon(gIconDir + os.sep + 'pyscript.png'))
            else:
                parent.setWindowIcon(QIcon(gIconDir + os.sep + 'new.png'))

        monoFont = QFont('Courier New')
        monoFont.setFixedPitch(True)
        self.setFont(monoFont)
        self.setWordWrapMode(QTextOption.NoWrap)
        ## self.setTextBackgroundColor(QColor('#000000'))
        ## self.setTextColor(QColor('#FFFFFF'))
        self.setCursorWidth(2)
        self.CreateActions()

        self.zoomLevel = 0

        gMainWin.action_Edit_Cut.setEnabled(False)
        gMainWin.action_Edit_Copy.setEnabled(False)
        self.copyAvailable.connect(gMainWin.action_Edit_Cut.setEnabled)
        self.copyAvailable.connect(gMainWin.action_Edit_Copy.setEnabled)
        # Handle the Context Menu Entries Also.
        self.action_Edit_Undo.setEnabled(False)
        self.action_Edit_Redo.setEnabled(False)
        self.action_Edit_Cut.setEnabled(False)
        self.action_Edit_Copy.setEnabled(False)
        self.undoAvailable.connect(self.action_Edit_Undo.setEnabled)
        self.redoAvailable.connect(self.action_Edit_Redo.setEnabled)
        self.copyAvailable.connect(self.action_Edit_Cut.setEnabled)
        self.copyAvailable.connect(self.action_Edit_Copy.setEnabled)

        self.document().contentsChanged.connect(self.TheDocumentWasModified)

        # self.show()
        # self.showMaximized()
        # self.setFocusPolicy(Qt.WheelFocus)
        ##### self.setFocus() # This makes the MDIArea go into SubWindowView...?

        self.gCornerWidget = QToolButton(self)
        # self.gCornerWidgetToolTip = QToolTip()
        QToolTip.setFont(QFont('SansSerif', 10))
        br = QBrush(QPixmap(gImgDir + os.sep + 'texture-spirals.png'))
        pal = QPalette()
        # pal.setBrush(QPalette.Active, QPalette.Base, br)
        # pal.setColor(QPalette.Background, QColor('#FF8000'))
        pal.setColor(QPalette.ColorGroup.Inactive,
                     QPalette.ColorRole.ToolTipBase,
                     QColor(EMBROIDERBLUE2))
        QToolTip.setPalette(QPalette(pal))
        self.action_Edit_SelectAll.setToolTip('This is a <b>QWidget</b> widget')

        self.gCornerWidget.setDefaultAction(self.action_Edit_SelectAll)
        self.setCornerWidget(self.gCornerWidget)
        # We want to show the corner widget no matter what so...
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
开发者ID:JTrantow,项目名称:Embroidermodder,代码行数:78,代码来源:mdisubwindow_textedit.py

示例3: ScriptSetVal

# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFixedPitch [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.setFixedPitch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。