代码拉取完成,页面将自动刷新
同步操作将从 终點起點/PySide6-UI-Demo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import sys
import os
import random
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *
class Demo(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
toolBar=QToolBar()
toolBar.addWidget(QLabel('CustomColor:'))
self.custom=QLineEdit()
#self.custom.setText('#ffff00')
toolBar.addWidget(self.custom)
toolBar.addWidget(QLabel("Options:"))
self.optonCombox=QComboBox()
self.optonCombox.addItems(QColorDialog.ColorDialogOption.__members__.keys())
toolBar.addWidget(self.optonCombox)
btn=QPushButton('ShowColorDialog')
btn.clicked.connect(self.OnShowDialog)
toolBar.addWidget(btn)
layout.addWidget(toolBar)
self.label=QLabel('Hello 测试颜色选择')
layout.addWidget(self.label)
self.setLayout(layout)
def OnShowDialog(self):
dialog=QColorDialog()#全局的,每次加的自定义颜色都被保留了
if len(self.custom.text())>0:
index=random.randint(0,dialog.customCount())
dialog.setCustomColor(index,self.custom.text())
self.parent.OnShowMessage(f'Set CustomColor {self.custom.text()} at {index}')
option=QColorDialog.ColorDialogOption[self.optonCombox.currentText()]
color= dialog.getColor(self.label.palette().color(QPalette.ColorRole.WindowText),self,'Select Color',option)
if color.isValid():
palette=self.label.palette()
palette.setColor(QPalette.ColorRole.WindowText,color)
self.label.setPalette(palette)
self.parent.OnShowMessage(f'Selected Color:{color.name()}')
def runDemo(parent):
wigdet = Demo(parent)
return wigdet
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。