代码拉取完成,页面将自动刷新
import sys
import os
import datetime
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *
from pyqtutil import *
class Demo(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignmentFlag.AlignTop)
toolBar=QToolBar()
cb = QCheckBox('CalendarPopup')
cb.stateChanged.connect(self.OnCalendarPopupChanged)
toolBar.addWidget(cb)
toolBar.addWidget(QLabel('Section:'))
section =QComboBox()
section.addItems(QDateTimeEdit.Section.__members__.keys())
section.currentTextChanged.connect(self.OnSectionChanged)
toolBar.addWidget(section)
toolBar.addWidget(QLabel('DisplayFormat:'))
self.displayFormat =QLineEdit()
self.displayFormat.editingFinished.connect(self.SetDisplayFormat)
toolBar.addWidget(self.displayFormat)
layout.addWidget(toolBar)
self.dateTimeEdit=QDateTimeEdit()#默认就是本地时间
time= datetime.datetime.now()
#dt=QDateTime(time.year,time.month,time.day,time.hour,time.minute,time.second)
self.dateTimeEdit.setDateTime(PyQtUtil.QDateTime.fromPython(time))
layout.addWidget(self.dateTimeEdit)
self.setLayout(layout)
def OnCalendarPopupChanged(self,state):
self.dateTimeEdit.setCalendarPopup(state)
self.parent.OnShowMessage(f"Set CalendarPopup={state}")
def OnSectionChanged(self,text):
section = QDateTimeEdit.Section[text]
self.dateTimeEdit.setSelectedSection(section)
self.parent.OnShowMessage(f'Set SelectedSection: {section}')
def SetDisplayFormat(self):
format = self.displayFormat.text()
self.dateTimeEdit.setDisplayFormat(format)
self.parent.OnShowMessage(f'Set DisplayFormat: {format}')
def runDemo(parent):
wigdet = Demo(parent)
return wigdet
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。