2 Star 10 Fork 7

终點起點/PySide6-UI-Demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
MessageBox.py 2.88 KB
一键复制 编辑 原始数据 按行查看 历史
终點起點 提交于 2024-08-23 16:48 +08:00 . 增加其他demo
import sys
import os
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)
self.label=QLabel('Result')
layout.addWidget(self.label)
btn=QPushButton('ShowAbout')
btn.clicked.connect(self.ShowAbout)
layout.addWidget(btn)
btn=QPushButton('ShowCritical')
btn.clicked.connect(self.ShowCritical)
layout.addWidget(btn)
btn=QPushButton('ShowInformation')
btn.clicked.connect(self.ShowInformation)
layout.addWidget(btn)
btn=QPushButton('ShowQuestion')
btn.clicked.connect(self.ShowQuestion)
layout.addWidget(btn)
btn=QPushButton('ShowWarning')
btn.clicked.connect(self.ShowWarning)
layout.addWidget(btn)
btn=QPushButton('ShowCustomInformation')
btn.clicked.connect(self.ShowCustomInformation)
layout.addWidget(btn)
self.setLayout(layout)
def ShowAbout(self):
result= QMessageBox.about(self,'About','This is Demo')
self.label.setText(f"Result:{result}")
def ShowCritical(self):
result=QMessageBox.critical(self,'Critical','ShowCritical',QMessageBox.StandardButton.Yes,QMessageBox.StandardButton.No)
self.label.setText(f"Result:{result}")
def ShowInformation(self):
result=QMessageBox.information(self,'Information','ShowInformation',QMessageBox.StandardButton.Ok)
self.label.setText(f"Result:{result}")
def ShowQuestion(self):
result=QMessageBox.question(self,'Question','ShowQuestion',QMessageBox.StandardButton.Yes,QMessageBox.StandardButton.No)
self.label.setText(f"Result:{result}")
def ShowWarning(self):
result=QMessageBox.warning(self,'Warning','ShowWarning',QMessageBox.StandardButton.Apply,QMessageBox.StandardButton.Ignore)
self.label.setText(f"Result:{result}")
def ShowCustomInformation(self):
msg=QMessageBox(self)
msg.setWindowTitle('Information')
msg.setInformativeText('Information Context')
msg.setDetailedText('Information Detail')
msg.setStandardButtons(QMessageBox.StandardButton.Save|QMessageBox.StandardButton.Ignore|QMessageBox.StandardButton.Cancel)
msg.setDefaultButton(QMessageBox.StandardButton.Save)
msg.setIcon(QMessageBox.Icon.Information)
btn=QPushButton('CustmButton')
btn.clicked.connect(msg.done(500))
msg.addButton(btn,QMessageBox.ButtonRole.NoRole)
result=msg.exec()
self.label.setText(f"Result:{result}")
if msg.clickedButton()==btn:
self.label.setText(self.label.text()+f"\n CustomButton Clicked")
def runDemo(parent):
wigdet = Demo(parent)
return wigdet
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/johnjiangw/pyside6-ui-demo.git
git@gitee.com:johnjiangw/pyside6-ui-demo.git
johnjiangw
pyside6-ui-demo
PySide6-UI-Demo
master

搜索帮助