pyqt5 单元格 -ag凯发k8国际
设置单元格字体和颜色
import sys from pyqt5.qtwidgets import qwidget, qtablewidget, qhboxlayout, qapplication, qtablewidgetitem from pyqt5.qtgui import qbrush, qcolor, qfont class cellfontandcolor(qwidget):def __init__(self):super(cellfontandcolor,self).__init__()self.initui()def initui(self):self.setwindowtitle("设置单元格字体和颜色")self.resize(430, 230);layout = qhboxlayout()tablewidget = qtablewidget()tablewidget.setrowcount(4)tablewidget.setcolumncount(3)layout.addwidget(tablewidget)tablewidget.sethorizontalheaderlabels(['姓名', '性别', '体重(kg)'])newitem = qtablewidgetitem('雷神')newitem.setfont(qfont('times',14,qfont.black))newitem.setforeground(qbrush(qcolor(255,0,0)))tablewidget.setitem(0,0,newitem)newitem = qtablewidgetitem('女')newitem.setforeground(qbrush(qco总结
- 上一篇:
- 下一篇: