代码拉取完成,页面将自动刷新
同步操作将从 终點起點/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()
toolBar = QToolBar()
btn = QPushButton('Add')
btn.clicked.connect(self.OnAddClicked)
toolBar.addWidget(btn)
btn = QPushButton('Insert')
btn.clicked.connect(self.OnInsertClicked)
toolBar.addWidget(btn)
'''btn = QPushButton('Delete')
btn.clicked.connect(self.OnDeleteClicked)
toolLayout.addWidget(btn)'''
layout.addWidget(toolBar)
self.toolbox = QToolBox()
self.toolbox.currentChanged.connect(self.OnCurrentChanged)
buttonWidget = QWidget()
self.buttonLayout = QVBoxLayout()
self.buttonLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
self.buttonLayout.addWidget(QPushButton('PushButton',objectName='PushButton'))
self.buttonLayout.addWidget(QRadioButton('RadioButton',objectName='RadioButton'))
toolbtn=QToolButton(objectName='ToolButton')
toolbtn.setIcon(QIcon(f'{self.parent.getAppDir()}/resources/confirm.png'))
self.buttonLayout.addWidget(toolbtn)
self.buttonLayout.addWidget(QCommandLinkButton('CommandLikButton',objectName='CommandLikButton'))
buttonWidget.setLayout(self.buttonLayout)
self.toolbox.addItem(buttonWidget,'Buttons')
#self.toolbox.addItem(QPushButton('PushButton'),'Buttons')
#self.toolbox.addItem(QRadioButton('RadioButton'),'Buttons')
#self.toolbox.addItem(QToolButton(),'Buttons')
#self.toolbox.addItem(QCommandLinkButton('CommandLikButton'),'Buttons')
self.toolbox.addItem(QListView(),'Views')
layout.addWidget(self.toolbox)
self.setLayout(layout)
def OnAddClicked(self):
widgetName = f'Checkbox{random.randint(1,100)}'
self.buttonLayout.addWidget(QCheckBox(widgetName,objectName=widgetName))
self.parent.OnShowMessage(f"Add Checkbox:{widgetName}")
def OnInsertClicked(self):
index = self.toolbox.currentIndex()
if index ==-1:
index=0
widgetName = f'Checkbox{random.randint(1,100)}'
self.buttonLayout.insertWidget(index,QCheckBox(widgetName,objectName=widgetName))
self.parent.OnShowMessage(f"Insert {widgetName} at {index}")
'''def OnDeleteClicked(self):
current = self.toolbox.currentWidget()
if current is None:return
self.parent.OnShowMessage(f"Delete item,Name={current.objectName()}")
self.buttonLayout.removeWidget(current)'''
def OnCurrentChanged(self,index):
self.parent.OnShowMessage(f"Current index={index}")
def runDemo(parent):
wigdet = Demo(parent)
return wigdet
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。