提交 d920f62c 编写于 作者: 小康2022

version 2.6.9

上级 c276bc58
ChangeLog/更新日志
=================
[`2.6.9.dev1`] - 2023-08-08
---------------------------
[`2.6.9`] - 2023-08-09
----------------------
### Added/新增
......@@ -33,6 +33,11 @@ ChangeLog/更新日志
- [X] Optimized the method `wm_geometry` of class `Tk` to accommodate some specially formatted parameters
优化了类 `Tk` 的方法 `wm_geometry` 以适应某些特殊格式的参数
### Removed/移除
- [X] Removed class `Singleton` and function `move`
移除了类 `Singleton` 和函数 `move`
[`2.6.8`] - 2023-08-03
----------------------
......
......@@ -9,7 +9,7 @@ The `tkintertools` module is an auxiliary module of the `tkinter` module
[![Version](https://img.shields.io/pypi/v/tkintertools?label=Version)](.)
[![License](https://img.shields.io/pypi/l/tkintertools?label=License)](LICENSE.txt)
[![ChangeLog](https://img.shields.io/badge/ChangeLog-2023/08/08-orange)](CHANGELOG.md)
[![ChangeLog](https://img.shields.io/badge/ChangeLog-2023/08/09-orange)](CHANGELOG.md)
[![ToDo](https://img.shields.io/badge/ToDo-14-yellow)](TODO.md)
[![Size](https://img.shields.io/github/languages/code-size/Xiaokang2022/tkintertools?label=Size)](tkintertools)
[![Wiki](https://img.shields.io/badge/Wiki-14-purple)](https://github.com/Xiaokang2022/tkintertools/wiki)\
......@@ -27,15 +27,15 @@ Install/模块安装👇
### Stable Version/稳定版本
* Version/最新版本 : `2.6.8`
* Release/发布日期 : 2023/08/03 (UTC+08)
* Version/最新版本 : `2.6.9`
* Release/发布日期 : 2023/08/09 (UTC+08)
这个是目前的最新稳定版,相对于开发版本而言比较稳定,bug 大体上是没有那么多的,推荐使用这个。稳定版和开发版相比,它在发布之前有个测试的步骤,经过测试之后(各项功能正常运行,多平台兼容)才会发布。
**PIP Cmd/安装命令:**
```
pip install tkintertools==2.6.8
pip install tkintertools==2.6.9
```
### Development Version/开发版本
......@@ -72,17 +72,19 @@ pip install tkintertools==2.6.9.dev1
![Python3.11.*](https://img.shields.io/badge/Python-3.11.*-blue?logo=python)
![Python3.12.*](https://img.shields.io/badge/Python-3.12.*-blue?logo=python)
如果拥有 PIL 库,则 tkintertools 会运行得更快,但 PIL 并不是必须的,没有 PIL 的情况下 tkintertools 依然可以正常使用。
News/最新功能👇
--------------
### Release Notes/版本说明
**最新版本: `tkintertools-v2.6.9.dev1`**
**最新版本: `tkintertools-v2.6.9`**
> **Note**
> tkintertools 的介绍、使用教程和开发文档均在 [Wiki](https://github.com/Xiaokang2022/tkintertools/wiki) 中,大家可前往查阅
下面是本次开发版本(`v2.6.8` -> `v2.6.9.dev1`)的更新内容条目:
下面是本次开发版本(`v2.6.8` -> `v2.6.9`)的更新内容条目:
- [X] Added new widget switch (`Switch`)
新增控件开关(`Switch`
......@@ -98,12 +100,14 @@ News/最新功能👇
`CheckButton` 的位置参数 `length` 更名为 `height`
- [X] Optimized the method `wm_geometry` of class `Tk` to accommodate some specially formatted parameters
优化了类 `Tk` 的方法 `wm_geometry` 以适应某些特殊格式的参数
- [X] Removed class `Singleton` and function `move`
移除了类 `Singleton` 和函数 `move`
### Template Demo/模板演示
下面是一个主要新功能的示例程序,即新增控件:开关!这个控件可以调整长宽、颜色、以及圆角的大小!
下面是示例程序的效果图(运行环境为 Windows11-Python3.11.4):
下面是示例程序的效果图(运行环境为 **Windows11 家庭中文版 23H2 - Python3.11.4**):
![news](news.png)
......
......@@ -27,8 +27,8 @@ Contents
--------
* Container Widgets: `Tk`, `Toplevel`, `Canvas`
* Virtual Canvas Widgets: `Label`, `Button`, `CheckButton`, `Entry`, `Text`, `Progressbar`,`ToolTip`, `Switch`
* Tool Functions: `move`, `text`, `color`, `askfont`, `SetProcessDpiAwareness`
* Tool Classes: `PhotoImage`, `Singleton`, `Animation`
* Tool Functions: `text`, `color`, `askfont`, `SetProcessDpiAwareness`
* Tool Classes: `PhotoImage`, `Animation`
* Tool Submodules: `tool_3d`
More
......@@ -48,14 +48,14 @@ from .__main__ import *
from .constants import *
__author__ = 'Xiaokang2022<2951256653@qq.com>'
__version__ = '2.6.9.dev1'
__version__ = '2.6.9'
__all__ = [
# Container Widgets
'Tk', 'Toplevel', 'Canvas',
# Virtual Canvas Widgets
'Label', 'Button', 'CheckButton', 'Entry', 'Text', 'Progressbar', 'ToolTip', 'Switch',
# Tool Classes
'PhotoImage', 'Singleton', 'Animation',
'PhotoImage', 'Animation',
# Tool Functions
'move', 'text', 'color', 'askfont', 'SetProcessDpiAwareness',
'text', 'color', 'askfont', 'SetProcessDpiAwareness',
] + all_constants
......@@ -1658,7 +1658,7 @@ class Animation:
def _translate(self, dx, dy): # type: (int, int) -> None
""" 平移 """
if isinstance(self.widget, tkinter.Tk | tkinter.Toplevel): # 窗口
if isinstance(self.widget, (tkinter.Tk, tkinter.Toplevel)): # 窗口
size, x, y = self.widget.geometry().split('+')
self.widget.geometry('%s+%d+%d' % (size, int(x)+dx, int(y)+dy))
elif isinstance(self.widget, tkinter.Widget): # tkinter 控件
......@@ -1676,117 +1676,6 @@ class Animation:
self._run()
class Singleton(object):
""" 单例模式类 """
_instance = None
def __new__(cls, *args, **kw):
print('Deprecation Warning: Class `Singleton` is about to be deprecated.')
if not cls._instance:
cls._instance = object.__new__(cls)
return cls._instance
@overload
def move(
master, # type: Tk | Canvas | tkinter.Misc | tkinter.BaseWidget | None
widget, # type: Canvas | BaseWidget | tkinter.BaseWidget
dx, # type: int
dy, # type: int
times, # type: int
*,
mode, # type: Literal['smooth', 'rebound', 'flat']
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
...
@overload
def move(
master, # type: Tk | Canvas | tkinter.Misc | tkinter.BaseWidget | None
widget, # type: Canvas | BaseWidget | tkinter.BaseWidget
dx, # type: int
dy, # type: int
times, # type: int
*,
mode, # type: tuple[Callable[[float], float], float, float]
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
...
def move(
master, # type: Tk | Canvas | tkinter.Misc | tkinter.BaseWidget | None
widget, # type: Canvas | BaseWidget | tkinter.BaseWidget
dx, # type: int
dy, # type: int
times, # type: int
*,
mode,
# type: tuple[Callable[[float], float], float, float] | Literal['smooth', 'rebound', 'flat']
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
"""
### 移动函数
以特定方式移动由 Place 布局的某个控件或某些控件的集合或图像 \
或者按一定的函数规律来移动
---
`master`: 控件所在的父控件 \
`widget`: 要移动位置的控件 \
`dx`: 横向移动的距离(单位:像素) \
`dy`: 纵向移动的距离(单位:像素) \
`times`: 移动总时长(单位:毫秒) \
`mode`: 移动速度模式,为 smooth(顺滑)、rebound(回弹)和 flat(平移)这三种,或者为元组 (函数, 起始值, 终止值) 的形式 \
`frames`: 帧数,越大移动就越流畅,但计算越慢(范围为 1~100) \
`end`: 移动结束时执行的函数
"""
if _ind: # 记忆值
dis = mode
elif mode == 'flat': # 平滑模式
return move(master, widget, dx, dy, times, mode=(lambda _: 1, 0, 1), frames=frames, end=end)
elif mode == 'smooth': # 流畅模式
return move(master, widget, dx, dy, times, mode=(math.sin, 0, math.pi), frames=frames, end=end)
elif mode == 'rebound': # 回弹模式
return move(master, widget, dx, dy, times, mode=(math.cos, 0, 0.6*math.pi), frames=frames, end=end)
else: # 函数模式
func, start, stop, count = *mode, round(times*frames/1000)
interval = (stop-start) / count
dis = tuple(func(start+interval*i) for i in range(1, count+1))
key = 1 / sum(dis)
dis = tuple((key*i*dx, key*i*dy) for i in dis)
if widget is None: # 窗口
geometry, ox, oy = master.geometry().split('+')
master.geometry(
'%s+%d+%d' % (geometry, int(ox)+dis[_ind][0], int(oy)+dis[_ind][1]))
elif isinstance(master, tkinter.Misc) and isinstance(widget, tkinter.BaseWidget): # tkinter 的控件
place_info = widget.place_info()
origin_x, origin_y = float(place_info['x']), float(place_info['y'])
widget.place(x=origin_x+dis[_ind][0], y=origin_y+dis[_ind][1])
elif isinstance(master, Canvas) and isinstance(widget, BaseWidget): # 虚拟画布控件
widget.move(dis[_ind][0], dis[_ind][1])
elif isinstance(widget, int): # tkinter._CanvasItemId
master.move(widget, dis[_ind][0], dis[_ind][1])
else: # 其他自定义情况
widget.move(dis[_ind][0], dis[_ind][1])
if _ind+1 == round(times*frames/1000): # 停止条件
# NOTE: Deprecated
print('Deprecation Warning: The function `move` is about to be deprecated, please use the class `Animation` instead.')
return end() if end else None
master.after(
round(times/frames),
lambda: move(master, widget, dx, dy, times, mode=dis, frames=frames, end=end, _ind=_ind+1)) # 间隔一定时间执行函数
def text(
length, # type: int
string, # type: str
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册