五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

氣輕PyQt6 32 表-背景顏色文字顏色

2023-06-05 08:06 作者:氣輕  | 我要投稿

?

單元背景顏色和文字顏色的處理執(zhí)行后都無法立刻顯示,update(),viewport().update()以及repaint()等處理都試過,但都沒效果。

?

from PyQt6.QtWidgets import *

from PyQt6.QtGui import QBrush,QColor,QFont

import sys

?

treat = ['背景顏色','文字顏色']

class PyQt632(QWidget):

??? def __init__(self):

??????? super().__init__()

??????? self.initUI()

??? def initUI(self):

??????? self.setWindowTitle('氣輕PyQt6')??????????????? # 設(shè)置窗口標(biāo)題

??????? self.resize(490, 300)?????????????? ????????????# 設(shè)置窗口大小

??????? self.setStyleSheet('background-color:#FFC1C1')

?

??????? self.bgColor = QPushButton(treat[0], self)

??????? self.bgColor.setGeometry(10, 120, 80, 30)

??????? self.bgColor.setStyleSheet('background-color:#F5DEB3;color : #8B8682; \

??????????????????? font: bold large /"SimSun/";font-size:16px')

??????? self.bgColor.clicked.connect(lambda :self.buttonClicked(self.bgColor))

?

??????? self.textColor = QPushButton(treat[1], self)

??????? self.textColor.setGeometry(10, 150, 80, 30)

??? ????self.textColor.setStyleSheet('background-color:#F5DEB3;color : #8B8682; \

??????????????????? font: bold large /"SimSun/";font-size:16px')

??????? self.textColor.clicked.connect(lambda :self.buttonClicked(self.textColor))

?

??????? titles = ['編號', ' 第一列 ', ' 第二列 ', ' 第三列 ', ' 第四列 ']

??????? self.table = QTableWidget(8,5,self)???????????? # 創(chuàng)n行m列建空表格

??????? self.table.setGeometry(100, 60,380,200)???????? # 設(shè)置位置和大小

??????? self.table.setStyleSheet('background-color:#E6E6FA;color : #696969; \

???????????? ???????font: bold italic large /"Times New Roman/";font-size:16px')

??????? self.table.setHorizontalHeaderLabels(titles)??? # 水平標(biāo)題

??????? vtitle = list(map(str, list(range(8))))

??????? self.table.setVerticalHeaderLabels(vtitle)????? # 垂直標(biāo)題

????????????? ??????????????????????????????????????????# 自動調(diào)整列寬

??????? self.table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)

?

??????? self.table.setAlternatingRowColors(True)??????? # 行自動變色

??????? self.table.setFont(QFont("宋體",20))

?

??????? item=QTableWidgetItem('氣輕')

??????? self.table.setItem(0,0, item)

???????

??????? item=QTableWidgetItem('氣輕python')

??????? self.table.setItem(2,0, item)

???????

??????? item=QTableWidgetItem('氣輕PyQt6')

??????? self.table.setItem(4,0, item)

???????

??????? self.show()

?

??? def buttonClicked(self,b):

??????? action = b.text()

??????? rno = self.table.currentRow()

??????? cno = self.table.currentColumn()

?

??????? if rno == -1 or? cno== -1:????????????????????? # 無效位置?

??????????? reply = QMessageBox()

??????????? reply.setText('請選擇有效位置')

??????????? reply.setStandardButtons(QMessageBox.StandardButton.Yes)

??????????? x = reply.exec()

??????????? return

?

??????? reply = QMessageBox()

?

??????? col = QColorDialog.getColor()

?

??????? if not col.isValid():

??????????? reply = QMessageBox()

??????????? reply.setText('請選擇有效顏色')

??????????? reply.setStandardButtons(QMessageBox.StandardButton.Yes)

??????????? x = reply.exec()

??????????? return

?

??????? func = [self.table.item(rno,cno).setBackground,

??????????????? self.table.item(rno,cno).setForeground]

??????? fdict = dict(zip(treat,func))

??????? fdict[action](QBrush(QColor(col.name())))

?

if __name__ == '__main__':

??? app = QApplication(sys.argv)

??? window = PyQt632()

??? sys.exit(app.exec())

?

執(zhí)行結(jié)果


氣輕PyQt6 32 表-背景顏色文字顏色的評論 (共 條)

分享到微博請遵守國家法律
祥云县| 乐亭县| 五峰| 德兴市| 北票市| 察隅县| 越西县| 衡水市| 右玉县| 榆林市| 铜鼓县| 邻水| 衡山县| 镶黄旗| 土默特左旗| 菏泽市| 廊坊市| 平潭县| 贡嘎县| 曲靖市| 岳阳市| 广昌县| 新龙县| 上饶市| 德格县| 鄱阳县| 富平县| 和龙市| 汕头市| 惠州市| 将乐县| 宜春市| 连云港市| 永新县| 灯塔市| 西畴县| 翼城县| 敖汉旗| 托里县| 高雄县| 万山特区|