本文整理汇总了Python中PySide.QtGui.QTableWidgetItem.setFont方法的典型用法代码示例。如果您正苦于以下问题:Python QTableWidgetItem.setFont方法的具体用法?Python QTableWidgetItem.setFont怎么用?Python QTableWidgetItem.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QTableWidgetItem
的用法示例。
在下文中一共展示了QTableWidgetItem.setFont方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: appendTable
# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setFont [as 别名]
def appendTable(self, header, ws):
try:
font = QFont('TypeWriter', pointSize = 10, weight=QFont.Bold)
for text in header:
self.table.insertColumn(0)
for c in xrange(len(header)):
det = self.determine(header[c])
item = QTableWidgetItem(header[c])
if det == 0:
item.setBackground(QBrush(QColor('#FF8D00')))
else:
item.setBackground(QBrush(QColor('#005588')))
item.setFont(font)
item.setTextAlignment(Qt.AlignCenter)
self.table.setItem(0, c, item)
nComboBox = self.newCombo()
nComboBox.setCurrentIndex(det)
self.table.setCellWidget(1, c, (nComboBox))
for r in xrange(2,26,1):
item = QTableWidgetItem(ws[c][r-2])
item.setFont(font)
item.setTextAlignment(Qt.AlignCenter)
self.table.setItem(r, c, item)
self.addStatus( u' 狀態: 勤務表預覽成功', -1)
return 0
except:
self.addStatus( u' 狀態: 勤務表預覽失敗', 1)
return 'error'
示例2: insert_row
# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setFont [as 别名]
def insert_row(self, row, list_of_data):
self.insertRow(row)
for c, data_item in enumerate(list_of_data):
qtype = self.get_qtype(data_item)
newItem = QTableWidgetItem(type=qtype)
if type(data_item) == str:
newItem.setText(data_item)
else:
newItem.setData(QtCore.Qt.DisplayRole, data_item)
newItem.setFont(QFont("Helvetica", 12))
self.setItem(row, c, newItem)
示例3: __init__
# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setFont [as 别名]
def __init__(self, data_list, header_rows=0, roundit=None, cmap=None, click_handler=None, resize_columns=True, stretch_last=False, header_text=None, row_height=0, sort_column=0, sort_order=QtCore.Qt.AscendingOrder):
self._data_list = data_list
self._nrows = len(self._data_list)
self._ncols = len(self._data_list[0])
QTableWidget.__init__(self, self._nrows, self._ncols)
self.setWordWrap(True) # I think it is already true by default
if header_rows > 0:
self.setHorizontalHeaderLabels(self._data_list[0])
self._data_list = self._data_list[1:]
self._nrows -= 1
for r in range(self._nrows):
for c in range(self._ncols):
data_item = self._data_list[r][c]
qtype = self.get_qtype(data_item)
if (roundit != None) and (qtype == QFLOAT): # @UndefinedVariable
data_item = round(data_item, roundit)
if (r < header_rows - 1):
data_item = "_" + str(data_item) # do this so the header rows are sorted to the top
# newItem = QTableWidgetItem(str(data_item))
newItem = QTableWidgetItem(type=qtype)
if type(data_item) == str:
newItem.setText(data_item)
else:
newItem.setData(QtCore.Qt.DisplayRole, data_item)
if r < header_rows - 1:
newItem.setFont(QFont("Helvetica", 12, QFont.Bold))
else:
newItem.setFont(QFont("Helvetica", 12))
if (cmap != None) and (type(data_item) == float) and (r >= header_rows):
the_color = cmap.rgb_color_from_val(data_item)
newBrush = QBrush()
newBrush.setColor(QColor(the_color[0], the_color[1], the_color[2]))
newBrush.setStyle(QtCore.Qt.SolidPattern)
newItem.setBackground(newBrush)
self.setItem(r, c, newItem)
if resize_columns:
self.resizeColumnsToContents()
self.resizeRowsToContents()
self.sortItems(0, order=QtCore.Qt.AscendingOrder)
self.setSortingEnabled(True)
if row_height != 0:
vh = self.verticalHeader()
vh.setDefaultSectionSize(row_height)
if click_handler != None:
self._click_handler = click_handler
self.itemClicked.connect(self.item_click_action)
if stretch_last:
hh = self.horizontalHeader()
hh.setStretchLastSection(True)
self.roundit = roundit
self.header_rows = header_rows
示例4: setUpTable
# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setFont [as 别名]
def setUpTable(self):
self.table.horizontalHeader().setVisible(False)
for i in xrange(0, 26, 1):
self.vhfont = QFont('Times', pointSize = 10, weight=QFont.Bold)
timePos = i+6
if i == 0:
item = QTableWidgetItem(u'[標題]')
elif i == 1:
item = QTableWidgetItem(u'[設定]')
elif 2 < timePos < 24:
item = QTableWidgetItem(('{0}~{1}').format(timePos, timePos+1))
else:
item = QTableWidgetItem(('{0}~{1}').format(timePos-24, timePos-23))
item.setFont(self.vhfont)
item.setTextAlignment(Qt.AlignCenter)
self.table.setVerticalHeaderItem(i, item)
示例5: setupUi
# 需要导入模块: from PySide.QtGui import QTableWidgetItem [as 别名]
# 或者: from PySide.QtGui.QTableWidgetItem import setFont [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setFixedSize(800, 600)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.FilterLbl = QLabel(self.centralwidget)
self.FilterLbl.setGeometry(QtCore.QRect(30, 150, 60, 15))
self.FilterLbl.setObjectName("FilterLbl")
self.FilterCB = QComboBox(self.centralwidget)
self.FilterCB.setGeometry(QtCore.QRect(450, 150, 100, 22))
self.FilterCB.setObjectName("FilterCB")
self.FilterCB.addItem("")
self.FilterCB.addItem("")
self.FilterCB.addItem("")
self.FilterCB.addItem("")
self.FilterTF = QLineEdit(self.centralwidget)
self.FilterTF.setGeometry(QtCore.QRect(100, 150, 320, 20))
self.tableView = QTableWidget(self.centralwidget)
self.tableView.setGeometry(QtCore.QRect(10, 180, 781, 511))
self.tableView.setObjectName("tableView")
self.tableView.setColumnCount(4)
self.tableView.setRowCount(0)
item = QTableWidgetItem("Cena za kg/l")
self.tableView.setHorizontalHeaderItem(0, item)
item = QTableWidgetItem("Cena ze kus")
self.tableView.setHorizontalHeaderItem(1, item)
item = QTableWidgetItem(u"Gramaž")
self.tableView.setHorizontalHeaderItem(2, item)
item = QTableWidgetItem("Popis")
item.setTextAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
font = QtGui.QFont()
font.setPointSize(8)
item.setFont(font)
self.tableView.setHorizontalHeaderItem(3, item)
self.tableView.horizontalHeader().setStretchLastSection(True)
self.SaveBtn = QPushButton(self.centralwidget)
self.SaveBtn.setGeometry(QtCore.QRect(30, 10, 100, 23))
self.SaveBtn.setObjectName("SaveBtn")
self.PrintSelectedToFileBtn = QPushButton(self.centralwidget)
self.PrintSelectedToFileBtn.setGeometry(QtCore.QRect(225, 10, 100, 23))
self.PrintSelectedToFileBtn.setObjectName("PrintSelectedToFileBtn")
self.PriceForUnitTF = QLineEdit(self.centralwidget)
self.PriceForUnitTF.setGeometry(QtCore.QRect(100, 70, 113, 20))
self.PriceForUnitTF.setObjectName("PriceForUnitTF")
self.PriceForUnitLbl = QLabel(self.centralwidget)
self.PriceForUnitLbl.setGeometry(QtCore.QRect(30, 70, 60, 13))
self.PriceForUnitLbl.setObjectName("PriceForUnitLbl")
self.ArtikelTF = QLineEdit(self.centralwidget)
self.ArtikelTF.setGeometry(QtCore.QRect(100, 100, 113, 20))
self.ArtikelTF.setObjectName("ArtikelTF")
self.ArtikelLbl = QLabel(self.centralwidget)
self.ArtikelLbl.setGeometry(QtCore.QRect(30, 100, 46, 13))
self.ArtikelLbl.setObjectName("ArtikelLbl")
self.DescriptionLbl = QLabel(self.centralwidget)
self.DescriptionLbl.setGeometry(QtCore.QRect(455, 70, 75, 13))
self.DescriptionLbl.setObjectName("DescriptionLbl")
self.UnitLbl = QLabel(self.centralwidget)
self.UnitLbl.setGeometry(QtCore.QRect(250, 70, 60, 15))
self.UnitLbl.setObjectName("UnitLbl")
self.WeightLbl = QLabel(self.centralwidget)
self.WeightLbl.setGeometry(QtCore.QRect(250, 100, 60, 13))
self.WeightLbl.setObjectName("UnitLbl")
self.WeightTF = QLineEdit(self.centralwidget)
self.WeightTF.setGeometry(QtCore.QRect(320, 100, 100, 20))
self.WeightTF.setObjectName("WeightTF")
self.UnitCB = QComboBox(self.centralwidget)
self.UnitCB.setGeometry(QtCore.QRect(320, 70, 100, 22))
self.UnitCB.setObjectName("UnitCB")
self.UnitCB.addItem("")
self.UnitCB.addItem("")
self.DescriptionTE = QPlainTextEdit(self.centralwidget)
self.DescriptionTE.setGeometry(QtCore.QRect(540, 30, 241, 61))
self.DescriptionTE.setObjectName("DescriptionTE")
self.PrintToFileBtn = QPushButton(self.centralwidget)
self.PrintToFileBtn.setGeometry(QtCore.QRect(140, 10, 75, 23))
self.PrintToFileBtn.setObjectName("PrintToFileBtn")
self.AddRecordBtn = QPushButton(self.centralwidget)
self.AddRecordBtn.setGeometry(QtCore.QRect(450, 100, 75, 23))
self.AddRecordBtn.setObjectName("AddRecordBtn")
self.SaveChangeBtn = QPushButton(self.centralwidget)
self.SaveChangeBtn.setGeometry(QtCore.QRect(550, 100, 75, 23))
self.SaveChangeBtn.setObjectName("SaveChangeBtn")
self.DeleteRecordBtn = QPushButton(self.centralwidget)
self.DeleteRecordBtn.setGeometry(QtCore.QRect(650, 100, 75, 23))
self.DeleteRecordBtn.setObjectName("DeleteRecordBtn")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
self.FilterTF.textChanged.connect(self.on_lineEdit_textChanged)
self.FilterCB.currentIndexChanged.connect(self.on_comboBox_currentIndexChanged)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)