本文整理汇总了Python中PySide.QtGui.QFont.setFamily方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setFamily方法的具体用法?Python QFont.setFamily怎么用?Python QFont.setFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setFamily方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFamily [as 别名]
def paintEvent(self, pe):
painter = QPainter(self)
painter.save()
gradient = QLinearGradient()
gradient.setStart(self._grad_start)
gradient.setFinalStop(self._grad_end)
gradient.setColorAt(0, QColor(230, 230, 230))
gradient.setColorAt(1, QColor(247, 247, 247))
brush = QBrush(gradient)
painter.setBrush(brush)
pen = QPen(Qt.black)
pen.setWidth(1)
painter.setPen(pen)
painter.drawPath(self._painter_path)
painter.restore()
font = QFont()
font.setFamily("Tahoma")
font.setPixelSize(11)
font.setBold(True)
pen = QPen(Qt.darkGray)
painter.setPen(pen)
painter.setFont(font)
self_rect = QRect(self.rect())
self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
painter.drawText(self_rect, Qt.AlignLeft, self._text)
示例2: PlainText
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFamily [as 别名]
def PlainText(painter,widget):
painter.setPen(widget.textColor())
font = QFont()
font.setPixelSize(widget.fontSize())
font.setOverline(widget.overline())
font.setUnderline(widget.underlined())
font.setItalic(widget.italic())
font.setStrikeOut(widget.strikeOut())
font.setWeight(widget.fontWeight())
font.setFamily(widget.fontFamily())
font.setCapitalization( QFont.Capitalization(widget.textTransform()) )
font.setStretch(widget.fontStretch())
font.setLetterSpacing(QFont.SpacingType(widget.letterSpacingType()), widget.letterSpacing())
font.setWordSpacing(widget.wordSpacing())
painter.setFont(font)
painter.drawText(0,0,100,100,widget.textAlignment(),widget.text())
示例3: setObjectText
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFamily [as 别名]
def setObjectText(self, strng):
"""
TOWRITE
:param `strng`: TOWRITE
:type `strng`: QString
"""
self.objText = strng
textPath = QPainterPath()
font = QFont()
font.setFamily(self.objTextFont)
font.setPointSizeF(self.objTextSize)
font.setBold(self.objTextBold)
font.setItalic(self.objTextItalic)
font.setUnderline(self.objTextUnderline)
font.setStrikeOut(self.objTextStrikeOut)
font.setOverline(self.objTextOverline)
textPath.addText(0., 0., font, strng)
# Translate the path based on the justification.
jRect = textPath.boundingRect() # QRectF
if self.objTextJustify == "Left": textPath.translate(-jRect.left(), 0)
elif self.objTextJustify == "Center": textPath.translate(-jRect.center().x(), 0)
elif self.objTextJustify == "Right": textPath.translate(-jRect.right(), 0)
elif self.objTextJustify == "Aligned": pass # TODO: TextSingleObject Aligned Justification
elif self.objTextJustify == "Middle": textPath.translate(-jRect.center())
elif self.objTextJustify == "Fit": pass # TODO: TextSingleObject Fit Justification
elif self.objTextJustify == "Top Left": textPath.translate(-jRect.topLeft())
elif self.objTextJustify == "Top Center": textPath.translate(-jRect.center().x(), -jRect.top())
elif self.objTextJustify == "Top Right": textPath.translate(-jRect.topRight())
elif self.objTextJustify == "Middle Left": textPath.translate(-jRect.left(), -jRect.top()/2.0)
elif self.objTextJustify == "Middle Center": textPath.translate(-jRect.center().x(), -jRect.top()/2.0)
elif self.objTextJustify == "Middle Right": textPath.translate(-jRect.right(), -jRect.top()/2.0)
elif self.objTextJustify == "Bottom Left": textPath.translate(-jRect.bottomLeft())
elif self.objTextJustify == "Bottom Center": textPath.translate(-jRect.center().x(), -jRect.bottom())
elif self.objTextJustify == "Bottom Right": textPath.translate(-jRect.bottomRight())
# Backward or Upside Down.
if self.objTextBackward or self.objTextUpsideDown:
horiz = 1.0 # qreal
vert = 1.0 # qreal
if self.objTextBackward:
horiz = -1.0
if self.objTextUpsideDown:
vert = -1.0
flippedPath = QPainterPath()
element = QPainterPath.Element
P2 = QPainterPath.Element
P3 = QPainterPath.Element
P4 = QPainterPath.Element
for i in range(0, textPath.elementCount()): # for(int i = 0; i < textPath.elementCount(); ++i)
element = textPath.elementAt(i)
if element.isMoveTo():
flippedPath.moveTo(horiz * element.x, vert * element.y)
elif element.isLineTo():
flippedPath.lineTo(horiz * element.x, vert * element.y)
elif element.isCurveTo():
# start point P1 is not needed
P2 = textPath.elementAt(i) # control point
P3 = textPath.elementAt(i + 1) # control point
P4 = textPath.elementAt(i + 2) # end point
flippedPath.cubicTo(horiz * P2.x, vert * P2.y,
horiz * P3.x, vert * P3.y,
horiz * P4.x, vert * P4.y)
objTextPath = flippedPath
else:
objTextPath = textPath
# Add the grip point to the shape path.
gripPath = objTextPath # QPainterPath
gripPath.connectPath(objTextPath)
gripPath.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
self.setObjectPath(gripPath)
示例4: EditorWindow
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFamily [as 别名]
#.........这里部分代码省略.........
pass
#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')
示例5: __init__
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setFamily [as 别名]
def __init__(self, parent=None):
super(Truss, self).__init__(parent)
self.resize(800, 600)
self.filename = None
self.filetuple = None
self.dirty = False # Refers to Data Page only.
centralwidget = QWidget(self)
gridLayout = QGridLayout(centralwidget)
self.tabWidget = QTabWidget(centralwidget)
self.tab = QWidget()
font = QFont()
font.setFamily("Courier 10 Pitch")
font.setPointSize(12)
self.tab.setFont(font)
gridLayout_3 = QGridLayout(self.tab)
self.plainTextEdit = QPlainTextEdit(self.tab)
gridLayout_3.addWidget(self.plainTextEdit, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QWidget()
self.tab_2.setFont(font)
gridLayout_2 = QGridLayout(self.tab_2)
self.plainTextEdit_2 = QPlainTextEdit(self.tab_2)
gridLayout_2.addWidget(self.plainTextEdit_2, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_2, "")
gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
self.setCentralWidget(centralwidget)
menubar = QMenuBar(self)
menubar.setGeometry(QRect(0, 0, 800, 29))
menu_File = QMenu(menubar)
self.menu_Solve = QMenu(menubar)
self.menu_Help = QMenu(menubar)
self.setMenuBar(menubar)
self.statusbar = QStatusBar(self)
self.setStatusBar(self.statusbar)
self.action_New = QAction(self)
self.actionSave_As = QAction(self)
self.action_Save = QAction(self)
self.action_Open = QAction(self)
self.action_Quit = QAction(self)
self.action_About = QAction(self)
self.actionShow_CCPL = QAction(self)
self.action_Solve = QAction(self)
self.action_CCPL = QAction(self)
self.action_Help = QAction(self)
menu_File.addAction(self.action_New)
menu_File.addAction(self.action_Open)
menu_File.addAction(self.actionSave_As)
menu_File.addAction(self.action_Save)
menu_File.addSeparator()
menu_File.addAction(self.action_Quit)
self.menu_Solve.addAction(self.action_Solve)
self.menu_Help.addAction(self.action_About)
self.menu_Help.addAction(self.action_CCPL)
self.menu_Help.addAction(self.action_Help)
menubar.addAction(menu_File.menuAction())
menubar.addAction(self.menu_Solve.menuAction())
menubar.addAction(self.menu_Help.menuAction())
self.setWindowTitle("Main Window")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),\
"Data Page")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),\
"Solution Page")
menu_File.setTitle("&File")
self.menu_Solve.setTitle("&Solve")
self.menu_Help.setTitle("&Help")
self.tabWidget.setCurrentIndex(0)
self.action_New.setText("&New")
self.action_Open.setText("&Open")
self.actionSave_As.setText("Save &As")
self.action_Save.setText("&Save")
self.action_Quit.setText("&Quit")
self.action_Solve.setText("&Solve")
self.action_About.setText("&About")
self.action_CCPL.setText("&CCPL")
self.action_Help.setText("&Help")
self.action_Quit.triggered.connect(self.close)
allToolBar = self.addToolBar("AllToolBar")
allToolBar.setObjectName("AllToolBar")
self.addActions(allToolBar, (self.action_Open, self.actionSave_As,\
self.action_Save, self.action_Solve,\
self.action_Quit ))
self.action_New.triggered.connect(self.fileNew)
self.action_Open.triggered.connect(self.fileOpen)
self.actionSave_As.triggered.connect(self.fileSaveAs)
self.action_Save.triggered.connect(self.fileSave)
self.action_Solve.triggered.connect(self.trussSolve)
self.action_About.triggered.connect(self.aboutBox)
self.action_CCPL.triggered.connect(self.displayCCPL)
self.action_Help.triggered.connect(self.help)
self.plainTextEdit.textChanged.connect(self.setDirty)
self.action_New = self.editAction(self.action_New, None,\
'ctrl+N', 'filenew', 'New File.')
self.action_Open = self.editAction(self.action_Open, None,
'ctrl+O', 'fileopen', 'Open File.')
self.actionSave_As = self.editAction(self.actionSave_As,\
None, 'ctrl+A', 'filesaveas',\
'Save and Name File.')
self.action_Save = self.editAction(self.action_Save, None,
'ctrl+S', 'filesave', 'Save File.')
self.action_Solve = self.editAction(self.action_Solve, None,
#.........这里部分代码省略.........