本文整理汇总了Python中PySide.QtGui.QFont.setKerning方法的典型用法代码示例。如果您正苦于以下问题:Python QFont.setKerning方法的具体用法?Python QFont.setKerning怎么用?Python QFont.setKerning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QFont
的用法示例。
在下文中一共展示了QFont.setKerning方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initUI
# 需要导入模块: from PySide.QtGui import QFont [as 别名]
# 或者: from PySide.QtGui.QFont import setKerning [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)
#.........这里部分代码省略.........