本文整理汇总了Python中PySide.QtGui.QFont.setBold方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setBold方法的具体用法?Python QFont.setBold怎么用?Python QFont.setBold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setBold方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [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: paintEvent
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def paintEvent(self, event):
""" Paints the widgets:
- paints the background
- paint each visible blocks that intersects the widget bbox.
"""
painter = QPainter(self)
painter.fillRect(event.rect(), self.back_brush)
painter.setPen(self.text_pen)
painter.setFont(self.font)
w = self.width() - 2
# better name lookup speed
painter_drawText = painter.drawText
align_right = Qt.AlignRight
normal_font = painter.font()
normal_font.setBold(False)
bold_font = QFont(normal_font)
bold_font.setBold(True)
active = self.editor.codeEdit.textCursor().blockNumber()
for vb in self.editor.codeEdit.visible_blocks:
row = vb.row
if row == active + 1:
painter.setFont(bold_font)
else:
painter.setFont(normal_font)
painter_drawText(0, vb.top, w, vb.height, align_right,
str(row))
return Panel.paintEvent(self, event)
示例3: font
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def font(bold):
"""
Returns a `QFont` object to be used in `View` derived classes.
:param bold: Indicates whether or not the font will be bold
"""
font = QFont(View.fontFamily, 9, 50, False)
font.setBold(bold)
return font
示例4: __CreateGrid
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def __CreateGrid(self):
g1 = QGridLayout()
self.centralWidget().setLayout(g1)
g1.setSpacing(5)
bold = QFont()
bold.setBold(True)
self.__AddGridLabel(g1, 'Source Directory:', QFont(), 0, 0, -1)
self.__AddGridLabel(g1, 'Archive Directory:', QFont(), 1, 0, -1)
self.__AddGridLabel(g1, 'Target Directory:', QFont(), 2, 0, -1)
self.__AddGridLabel(g1, 'Max Number of Videos:', QFont(), 3, 0, -1)
self.__AddGridLabel(g1, 'Video File Types:', QFont(), 3, 2, -1)
#self.__AddGridLabel(g1, 'Max Run Time in Hours:', QFont(), 4, 2, -1)
g1.addWidget(self.qleSourceDir, 0, 1, 1, 3)
g1.addWidget(self.qleArchiveDir, 1, 1, 1, 3)
g1.addWidget(self.qleDestinationDir, 2, 1, 1, 3)
g1.addWidget(self.qleMaxVidsCap, 3, 1)
g1.addWidget(self.qleVideoTypes, 3, 3)
#g1.addWidget(self.qleRunTimeMax, 4, 3)
g1.addWidget(self.qpbRun, 10, 3, alignment = -1)
g1.addWidget(QLabel('', self), 4, 0,) # Empty Column As Separator
g1.addWidget(QLabel('', self), 5, 0,) # Empty Column As Separator
self.__AddGridLabel(g1, 'Videos Completed:', bold, 5, 0, -1)
self.__AddGridLabel(g1, 'Start Time:', bold, 5, 2, -1)
self.__AddGridLabel(g1, 'Videos In Progress:', bold, 6, 0, -1)
self.__AddGridLabel(g1, 'Time Remaining:', bold, 7, 2, -1)
self.__AddGridLabel(g1, 'Target Space Left:', bold, 7, 0, -1)
self.__AddGridLabel(g1, 'Archive Space Left:', bold, 8, 0, -1)
self.__AddGridLabel(g1, 'End Time:', bold, 6, 2, -1)
self.__AddGridLabel(g1, 'Processing Speed:', bold, 8, 2, -1)
g1.addWidget(self.qlVidsDone, 5, 1,)
g1.addWidget(self.qlVidsInProgress, 6, 1)
g1.addWidget(self.qlStartTime, 5, 3,)
g1.addWidget(self.qlEndTime, 6, 3,)
g1.addWidget(self.qlTimeLeft, 7, 3,)
g1.addWidget(self.qlDestinationSpace, 7, 1,)
g1.addWidget(self.qlArcSpace, 8, 1,)
g1.addWidget(self.qlProcessingSpeed, 8, 3,)
g1.addWidget(self.qpbSourceDir, 0, 4,)
g1.addWidget(self.qpbArchiveDir, 1, 4,)
g1.addWidget(self.qpbTargetDir, 2, 4,)
self.show
示例5: buildLabels
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def buildLabels(self, label):
self.label = QLabel(label)
self.data = QLabel(constants.DEFAULT_LABEL)
# Center the text in the labels
self.label.setAlignment(Qt.AlignCenter)
self.data.setAlignment(Qt.AlignCenter)
# Bold the label label
labelFont = QFont()
labelFont.setBold(True)
# Make the data label font obnoxiously large
dataFont = QFont()
dataFont.setPixelSize(20)
self.label.setFont(labelFont)
self.data.setFont(dataFont)
示例6: tag_image
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def tag_image(source, dest, tag, font, fontsize, x, y, width, height, aspectx, aspecty, red, green, blue, bold=False, italic=False):
"""docstring for tag_image"""
app = QApplication.instance()
pixmap = QPixmap(source)
color = QColor(red,green,blue)
font = QFont(font)
font.setPixelSize(int(fontsize*pixmap.height()))
font.setItalic(italic)
font.setBold(bold)
painter = QPainter(pixmap)
painter.setPen(color)
painter.setFont(font);
painter.drawText(x*pixmap.width(),y*pixmap.height(), tag)
painter.end()
# Resize and save
return pixmap.toImage().scaled(width*aspectx, height*aspecty, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation).scaled(width, height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation).save(dest)
示例7: setObjectText
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [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)
示例8: FoldPanel
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
class FoldPanel(Panel):
""" This Panel display folding indicators and manage folding/unfolding a text
The panel also handles line added/removed and update the indicators position automatically.
.. note:: It does not parse the code to put fold indicators, this is the task of a code folder mode. Instead it
provides an easy way for other modes to put fold indicators on the left margin.
"""
#: Panel identifier
IDENTIFIER = "Folding"
DESCRIPTION = "Display code folding indicators"
def __init__(self, parent=None):
Panel.__init__(
self, self.IDENTIFIER, self.DESCRIPTION, parent)
self.fold_indicators = []
self.setMouseTracking(True)
self.logger = logging.getLogger(
__name__ + "." + self.__class__.__name__)
def addIndicator(self, start, end):
"""
Adds a fold indicator
:param start: Start line (1 based)
:param end: End line
"""
self.fold_indicators.append(FoldIndicator(start, end))
self.update()
def removeIndicator(self, indicator):
"""
Remove a fold indicator
:param indicator: Indicator to remove
"""
self.fold_indicators.remove(indicator)
self.update()
def clearIndicators(self):
""" Remove all indicators """
self.fold_indicators[:] = []
self.update()
def install(self, editor):
""" Install the Panel on the editor """
Panel.install(self, editor)
self.bc = self.editor.codeEdit.blockCount()
self.__updateCursorPos()
def _onStateChanged(self, state):
Panel._onStateChanged(self, state)
if state is True:
self.editor.codeEdit.visibleBlocksChanged.connect(self.update)
self.editor.codeEdit.blockCountChanged.connect(self.__onBlockCountChanged)
self.editor.codeEdit.newTextSet.connect(self.__onNewTextSet)
self.editor.codeEdit.keyPressed.connect(self.__updateCursorPos)
else:
self.editor.codeEdit.visibleBlocksChanged.disconnect(self.update)
self.editor.codeEdit.blockCountChanged.disconnect(self.__onBlockCountChanged)
self.editor.codeEdit.newTextSet.disconnect(self.__onNewTextSet)
self.editor.codeEdit.keyPressed.disconnect(self.__updateCursorPos)
def _onStyleChanged(self):
""" Updates brushes and pens """
style = self.currentStyle
self.font = QFont(self.currentStyle.fontName, 7)
self.font.setBold(True)
fm = QFontMetricsF(self.editor.codeEdit.font())
self.size_hint = QSize(16, 16)
self.back_brush = QBrush(QColor(style.panelsBackgroundColor))
self.active_line_brush = QBrush(QColor(style.activeLineColor))
self.separator_pen = QPen(QColor(style.panelSeparatorColor))
self.normal_pen = QPen(QColor(style.lineNbrColor))
self.highlight_pen = QPen(QColor(style.tokenColor(Text)))
self.repaint()
def sizeHint(self):
""" Returns a fixed size hint (16x16) """
self.size_hint = QSize(16, 16)
return self.size_hint
def __onNewTextSet(self):
self.clearIndicators()
def getIndicatorForLine(self, line):
""" Returns the fold indicator whose start position equals the line
:param line: Line nbr of the start position of the indicator to get.
:return: FoldIndicator or None
"""
for m in self.fold_indicators:
if m.start == line:
return m
return None
def __updateCursorPos(self):
"""
Update tcPos and tcPosInBlock
:return:
"""
self.tcPos = self.editor.codeEdit.textCursor().blockNumber() + 1
#.........这里部分代码省略.........
示例9: initUI
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setBold [as 别名]
def initUI(self):
"""Met en place les éléments de l'interface."""
# -+++++++------------------- main window -------------------+++++++- #
self.setWindowTitle(u"Encodage / Décodage de Huffman")
self.centerAndResize()
centralwidget = QWidget(self)
mainGrid = QGridLayout(centralwidget)
mainGrid.setColumnMinimumWidth(0, 450)
# -+++++++------------------ groupe analyse -----------------+++++++- #
analysGroup = QGroupBox(u"Analyse", centralwidget)
self.analysGrid = QGridLayout(analysGroup)
# ----------- groupe de la table des codes ---------- #
codeTableGroup = QGroupBox(u"Table des codes", analysGroup)
codeTableGrid = QGridLayout(codeTableGroup)
# un tableau pour les codes
self.codesTableModel = MyTableModel()
self.codesTable = QTableView(codeTableGroup)
self.codesTable.setModel(self.codesTableModel)
self.codesTable.setFont(QFont("Mono", 8))
self.codesTable.resizeColumnsToContents()
self.codesTable.setSortingEnabled(True)
codeTableGrid.addWidget(self.codesTable, 0, 0, 1, 1)
self.analysGrid.addWidget(codeTableGroup, 1, 0, 1, 1)
# ----------- label du ratio de compression ---------- #
self.ratioLab = QLabel(u"Ratio de compression: ", analysGroup)
font = QFont()
font.setBold(True)
font.setWeight(75)
font.setKerning(True)
self.ratioLab.setFont(font)
self.analysGrid.addWidget(self.ratioLab, 2, 0, 1, 1)
# -+++++++-------- groupe de la table de comparaison --------+++++++- #
self.compGroup = QGroupBox(analysGroup)
self.compGroup.setTitle(u"Comparaisons")
compGrid = QGridLayout(self.compGroup)
# un tableau pour le ratio
self.compTable = QTableWidget(self.compGroup)
sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.compTable.sizePolicy().hasHeightForWidth())
self.compTable.setSizePolicy(sizePolicy)
self.compTable.setBaseSize(QSize(0, 0))
font = QFont()
font.setWeight(50)
self.compTable.setFont(font)
self.compTable.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.compTable.setShowGrid(True)
self.compTable.setGridStyle(Qt.SolidLine)
# lignes / colonnes
self.compTable.setColumnCount(2)
self.compTable.setRowCount(3)
self.compTable.setVerticalHeaderItem(0, QTableWidgetItem("Taille (bits)"))
self.compTable.setVerticalHeaderItem(1, QTableWidgetItem("Entropie"))
self.compTable.setVerticalHeaderItem(2, QTableWidgetItem("Taille moy. (bits)"))
for i in range(2):
self.compTable.verticalHeaderItem(i).setTextAlignment(
Qt.AlignRight)
self.compTable.setHorizontalHeaderItem(0, QTableWidgetItem("ASCII"))
self.compTable.setHorizontalHeaderItem(1, QTableWidgetItem("Huffman"))
# nom des items
self.compTabASCIIMem = QTableWidgetItem()
self.compTable.setItem(0, 0, self.compTabASCIIMem)
self.compTabASCIIEnt = QTableWidgetItem()
self.compTable.setItem(1, 0, self.compTabASCIIEnt)
self.compTabASCIIAvg = QTableWidgetItem()
self.compTable.setItem(2, 0, self.compTabASCIIAvg)
self.compTabHuffMem = QTableWidgetItem()
self.compTable.setItem(0, 1, self.compTabHuffMem)
self.compTabHuffEnt = QTableWidgetItem()
self.compTable.setItem(1, 1, self.compTabHuffEnt)
self.compTabHuffAvg = QTableWidgetItem()
self.compTable.setItem(2, 1, self.compTabHuffAvg)
# parem du tableau
self.compTable.horizontalHeader().setCascadingSectionResizes(False)
self.compTable.verticalHeader().setVisible(True)
font = QFont("Mono", 8)
self.compTable.setFont(font)
compGrid.addWidget(self.compTable, 1, 0, 1, 1)
self.analysGrid.addWidget(self.compGroup, 0, 0, 1, 1)
mainGrid.addWidget(analysGroup, 0, 1, 1, 1)
# -+++++++----------------- groupe du texte -----------------+++++++- #
groupBox = QGroupBox(u"Texte", centralwidget)
textGrid = QGridLayout(groupBox)
# -+++++++------------- groupe du texte original ------------+++++++- #
orgTextGroup = QGroupBox(u"Texte original (Ctrl+T)", groupBox)
orgTextGrid = QGridLayout(orgTextGroup)
self.orgText = QTextEdit(orgTextGroup)
self.orgText.setPalette(self.defaultPalette)
orgTextGrid.addWidget(self.orgText, 0, 0, 1, 1)
textGrid.addWidget(orgTextGroup, 0, 0, 1, 2)
# -+++++++------------ groupe du texte compressé ------------+++++++- #
compressedTextGroup = QGroupBox(u"Texte compressé (Ctrl+H)", groupBox)
compressedTextGrid = QGridLayout(compressedTextGroup)
self.compressedText = QTextEdit(compressedTextGroup)
self.compressedText.setPalette(self.defaultPalette)
compressedTextGrid.addWidget(self.compressedText, 0, 0, 1, 1)
textGrid.addWidget(compressedTextGroup, 1, 0, 1, 2)
#.........这里部分代码省略.........