diff --git a/examples/Gallery for siui/components/page_icons/page_icons.py b/examples/Gallery for siui/components/page_icons/page_icons.py index fbbe7a1..5408d42 100644 --- a/examples/Gallery for siui/components/page_icons/page_icons.py +++ b/examples/Gallery for siui/components/page_icons/page_icons.py @@ -1,6 +1,7 @@ -import pyperclip -from PySide6.QtCore import Qt +from PySide6.QtCore import Qt +from PySide6.QtWidgets import QApplication +from PySide6.QtGui import QClipboard from siui.components import ( SiDenseHContainer, SiDenseVContainer, @@ -20,7 +21,8 @@ def get_on_button_clicked_func(button): def on_button_clicked(): - pyperclip.copy(button.objectName()) + clipboard = QApplication.clipboard() + clipboard.setText(button.objectName()) SiGlobal.siui.windows["TOOL_TIP"].setText( f"{button.objectName()}
" f'复制成功', diff --git a/pdm.lock b/pdm.lock index 2822067..08f1d3b 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:e7091a148b3bf8afb7dfb09b38d792b84c93e1722d99b2850f57baca407ad28f" +content_hash = "sha256:d186037372963f10f50327d8e377f82720227f82c710a25ecbe4a5e847f5b73a" [[metadata.targets]] requires_python = "==3.12.*" @@ -28,15 +28,6 @@ files = [ {file = "numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010"}, ] -[[package]] -name = "pyperclip" -version = "1.9.0" -summary = "A cross-platform clipboard module for Python. (Only handles plain text for now.)" -groups = ["default"] -files = [ - {file = "pyperclip-1.9.0.tar.gz", hash = "sha256:b7de0142ddc81bfc5c7507eea19da920b92252b548b96186caf94a5e2527d310"}, -] - [[package]] name = "pyside6" version = "6.6.3.1" @@ -88,31 +79,6 @@ files = [ {file = "PySide6_Essentials-6.6.3.1-cp38-abi3-win_amd64.whl", hash = "sha256:31f7e70ada44d3cdbe6686670b3df036c720cfeb1dced0f7704e5f5a4be6a764"}, ] -[[package]] -name = "python-dateutil" -version = "2.9.0.post0" -requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -summary = "Extensions to the standard Python datetime module" -groups = ["default"] -dependencies = [ - "six>=1.5", -] -files = [ - {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, - {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, -] - -[[package]] -name = "setuptools" -version = "75.6.0" -requires_python = ">=3.9" -summary = "Easily download, build, install, upgrade, and uninstall Python packages" -groups = ["default"] -files = [ - {file = "setuptools-75.6.0-py3-none-any.whl", hash = "sha256:ce74b49e8f7110f9bf04883b730f4765b774ef3ef28f722cce7c273d253aaf7d"}, - {file = "setuptools-75.6.0.tar.gz", hash = "sha256:8199222558df7c86216af4f84c30e9b34a61d8ba19366cc914424cdbd28252f6"}, -] - [[package]] name = "shiboken6" version = "6.6.3.1" @@ -126,17 +92,6 @@ files = [ {file = "shiboken6-6.6.3.1-cp38-abi3-win_amd64.whl", hash = "sha256:88494b5e08a1f235efddbe2b0b225a3a66e07d72b6091fcc2fc5448572453649"}, ] -[[package]] -name = "six" -version = "1.17.0" -requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -summary = "Python 2 and 3 compatibility utilities" -groups = ["default"] -files = [ - {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, - {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, -] - [[package]] name = "typing-extensions" version = "4.12.2" diff --git a/pyproject.toml b/pyproject.toml index 3bb1ae3..cdddb6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,23 +4,20 @@ version = "1.0.1" authors = [ { name = "ChinaIceF", email = "ChinaIceF@outlook.com" }, { name = "rainzee wang", email = "rainzee.w@gmail.com" }, - {name = "H1DDENADM1N", email = "65646535+H1DDENADM1N@users.noreply.github.com"}, + { name = "H1DDENADM1N", email = "65646535+H1DDENADM1N@users.noreply.github.com" }, ] description = "Default template for PDM package" readme = "README.md" -license = { file = "LICENSE", text = "GPLv3"} +license = { file = "LICENSE", text = "GPLv3" } requires-python = "==3.12.*" dependencies = [ "PySide6==6.6.3.1", "typing-extensions>=4.12.2", - "python-dateutil>=2.9.0", - "setuptools>=75.6.0", "numpy==1.26.4", - "pyperclip>=1.9.0", ] [project.urls] -Repository = "hhttps://github.com/H1DDENADM1N/PySide6-SiliconUI" +Repository = "https://github.com/H1DDENADM1N/PySide6-SiliconUI" [tool.pdm] distribution = false diff --git a/setup.py b/setup.py deleted file mode 100644 index ca3933d..0000000 --- a/setup.py +++ /dev/null @@ -1,47 +0,0 @@ -from setuptools import find_packages, setup - -# 定义项目需要的依赖项 -install_requires = [ - "PySide6==6.6.3.1", - "numpy==1.26.4", - "pyperclip", -] - -# 定义项目元数据 -setup( - name = "PySide6-SiliconUI", - version = "1.01", - packages = find_packages(exclude = ["examples"]), # 自动找到所有包 - data_files=[("./siui/gui/icons/packages", ["./siui/gui/icons/packages/fluent_ui_icon_filled.icons", - "./siui/gui/icons/packages/fluent_ui_icon_regular.icons", - "./siui/gui/icons/packages/fluent_ui_icon_light.icons"]),], - include_package_data = True, - install_requires = install_requires, # 依赖项列表 - # 以下为可选元数据 - description = "A powerful and artistic UI library based on PySide6", # 包的简短描述 - long_description = open("README.md", encoding="utf-8").read(), # 包的详细描述,通常来自README文件 - long_description_content_type = "text/markdown", # README文件的格式 - url = "https://github.com/H1DDENADM1N/PySide6-SiliconUI", # 项目主页 - author = "H1DDENADM1N", # 作者名 - author_email = "sudoomg@outlook.com", # 作者邮箱 - license = "GPL-3.0", # 许可证 - classifiers=[ # 项目的分类信息 - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: GPL-3.0 License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - entry_points={ # 如果包是可执行的,定义入口点 - "console_scripts": [ - "" - ], - }, -) diff --git a/siui/components/widgets/timedate.py b/siui/components/widgets/timedate.py index 770fef7..3522348 100644 --- a/siui/components/widgets/timedate.py +++ b/siui/components/widgets/timedate.py @@ -2,7 +2,6 @@ import datetime import time -from dateutil.relativedelta import relativedelta from PySide6.QtCore import QPoint, Qt, Signal from PySide6.QtGui import QFont @@ -153,8 +152,33 @@ def __init__(self, *args, **kwargs): self.updateYearMonthLabel() def modifyDisplayedDate(self, month_delta): - self.displayed_date = self.displayed_date.replace(day=1) # 归一化,防止因日期引起的切换错误,日期不重要,月份重要 - self.displayed_date = self.displayed_date + relativedelta(months=month_delta) + # 归一化,防止因日期引起的切换错误,日期不重要,月份重要 + self.displayed_date = self.displayed_date.replace(day=1) + + # 计算新的年份和月份 + year = self.displayed_date.year + month = self.displayed_date.month + month_delta + + # 处理跨年的情况 + if month > 12: + year += (month - 1) // 12 + month = month % 12 or 12 + elif month < 1: + year += (month - 1) // 12 + month = month % 12 or 12 + + # 处理目标月份的天数差异 + try: + self.displayed_date = self.displayed_date.replace(year=year, month=month) + except ValueError: + # 如果目标月份没有当前日期的天数,则调整到目标月份的最后一天 + if month == 12: + next_month = datetime(year + 1, 1, 1) + else: + next_month = datetime(year, month + 1, 1) + last_day_of_month = next_month - datetime.timedelta(days=1) + self.displayed_date = last_day_of_month + self.updateCalendar() self.updateYearMonthLabel()