提交 27f979fd 编写于 作者: 小康2022

version 2.6.8.dev0

上级 eb2b4dbf
ChangeLog/更新日志
=================
[`2.6.8.dev0`] - 2023-07-20
---------------------------
### Added/新增
- [X] Added class `Animation` to achieve more efficient, convenient and functional animation effects
新增类 `Animation` 来实现更加高效、更加方便和功能性更强的动画效果
- [X] Added constant `CONTROL`
新增常量 `CONTROL`
### Changed/变更
- [X] Modified the name of the constant `FRAMES` to `FPS`
修改常量 `FRAMES` 的名称为 `FPS`
### Deprecated/弃用
- [X] The function `move` is about to be deprecated, please replace it with the new class `Animation`
函数 `move` 即将被弃用,请用新类 `Animation` 来代替
- [X] The class `Singleton` is about to be deprecated and singleton mode classes will no longer be available in subsequent releases
`Singleton` 即将被弃用,后续版本中将不再提供单例模式类
[`2.6.7`] - 2023-07-06
----------------------
### Features/新增
### Added/新增
- [X] The function `rotate` of the 3D submodule adds the keyword `axis` to provide the function of rotating around the axis
3D 子模块的函数 `rotate` 新增关键字参数 `axis` 来提供绕轴旋转的功能
......@@ -44,7 +68,7 @@ ChangeLog/更新日志
[`2.6.6`] - 2023-07-01
----------------------
### Features/新增
### Added/新增
- [X] The classes `_Point`, `_Line`, `_Side`, and `Geometry` of the 3D submodule all have a new method `center` that returns the geometric center of the 3D object
3D 子模块的类 `_Point``_Line``_Side``Geometry` 都新增一个方法 `center` 返回该 3D 对象的几何中心
......@@ -88,7 +112,7 @@ ChangeLog/更新日志
[`2.6.5`] - 2023-06-17
----------------------
### Features/新增
### Added/新增
- [X] The new class `Space` added to the submodule `tools_3d` can provide the ability to translate, rotate and scale 3D objects
子模块 `tools_3d` 新增类 `Space` 可以提供对 3D 对象进行平移、旋转和缩放等操作的功能
......@@ -112,7 +136,7 @@ ChangeLog/更新日志
[`2.6.4`] - 2023-06-12
----------------------
### Features/新增
### Added/新增
- [X] The class `tool_3d` submodule `Canvas_3D` has added the function `space_sort` to calculate and sort the actual position of space to support the correct display of geometry colors
`tool_3d` 子模块的类 `Canvas_3D` 新增对空间实际位置进行计算和排序的函数 `space_sort`,以支持几何体颜色的正确显示
......@@ -163,7 +187,7 @@ ChangeLog/更新日志
[`2.6.2`] - 2023-05-30
----------------------
### Features/新增
### Added/新增
- [X] Added `tkintertools` sub-module `tools_3d` to support drawing 3D graphics
新增 `tkintertools` 子模块 `tools_3d` 以支持绘制 3D 图形
......@@ -204,7 +228,7 @@ ChangeLog/更新日志
[`2.6.0`] - 2023-03-28
----------------------
### Features/新增
### Added/新增
- [X] New virtual canvas widget check box: `CheckButton`
新增虚拟画布控件复选框:`CheckButton`
......@@ -222,7 +246,7 @@ ChangeLog/更新日志
[`2.5.12`] - 2023-03-20
-----------------------
### Features/新增
### Added/新增
- [X] Add a `image` parameter to all widgets to add a background image
所有控件新增参数 `image` 来添加背景图片
......@@ -249,7 +273,7 @@ ChangeLog/更新日志
[`2.5.11`] - 2023-03-13
-----------------------
### Features/新增
### Added/新增
- [X] Class `Canvas` adds parameter `keep` to extend function
`Canvas` 新增参数 `keep` 以扩展功能
......@@ -282,7 +306,7 @@ ChangeLog/更新日志
[`2.5.10`] - 2023-02-04
-----------------------
### Features/新增
### Added/新增
- [X] Canvas virtual widget base class `_BaseWidget` Add instance attribute `command_ex` to extend functions
画布虚拟控件基类 `_BaseWidget` 新增实例属性 `command_ex` 以扩展功能
......@@ -317,7 +341,7 @@ ChangeLog/更新日志
[`2.5.9`] - 2023-01-13
----------------------
### Features/新增
### Added/新增
- [X] Class `PhotoImage` new method `stop` is used to stop the playback of moving pictures
`PhotoImage` 新增方法 `stop` 用于停止动图的播放
......@@ -374,7 +398,7 @@ ChangeLog/更新日志
[`2.5.7`] - 2023-01-10
----------------------
### Features/新增
### Added/新增
- [X] The `move` function adds the parameter `frames`, which can change the number of frames of the animation when moving
`move` 函数新增参数 `frames`,可改变移动时的动画的帧数
......@@ -436,7 +460,7 @@ ChangeLog/更新日志
[`2.5.5`] - 2022-12-11
----------------------
### Features/新增
### Added/新增
- [X] Added type prompt `Self` for the `self` parameter of instance methods of all classes
为所有类的实例方法的 `self` 参数添加了类型提示 `Self`
......@@ -462,7 +486,7 @@ ChangeLog/更新日志
[`2.5.4`] - 2022-12-08
----------------------
### Features/新增
### Added/新增
- [X] A new widget has been added: progress bar(`Progressbar`)
增加了一个新的控件:进度条(`Progressbar`
......@@ -494,7 +518,7 @@ ChangeLog/更新日志
[`2.5.3`] - 2022-11-27
----------------------
### Features/新增
### Added/新增
- [X] Added singleton pattern(`Singleton`) class for inheritance
增加了单例模式类(`Singleton`)供继承
......@@ -529,7 +553,7 @@ ChangeLog/更新日志
[`2.5.2`] - 2022-11-25
----------------------
### Features/新增
### Added/新增
- [X] Added mouse style for text type virtual widget
添加了对文本类虚拟控件的鼠标样式
......@@ -553,7 +577,7 @@ ChangeLog/更新日志
[`2.5.1`] - 2022-11-23
----------------------
### Features/新增
### Added/新增
- [X] Added mouse style for button virtual widgets
添加了对按钮虚拟控件的鼠标样式
......
......@@ -9,12 +9,12 @@ 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/07/06-orange)](CHANGELOG.md)
[![ToDo](https://img.shields.io/badge/ToDo-15-yellow)](TODO.md)
[![ChangeLog](https://img.shields.io/badge/ChangeLog-2023/07/20-orange)](CHANGELOG.md)
[![ToDo](https://img.shields.io/badge/ToDo-16-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)\
[![Downloads](https://img.shields.io/pypi/dm/tkintertools?label=Downloads&logo=pypi)](https://pypistats.org/packages/tkintertools)
[![Owner](https://img.shields.io/badge/Owner-Xiaokang2022-white?logo=about.me)](https://github.com/Xiaokang2022)
[![Owner](https://img.shields.io/badge/Owner-Xiaokang2022-white)](https://github.com/Xiaokang2022)
[![Blog](https://img.shields.io/badge/Blog-小康2022@CSDN-red)](https://xiaokang2022.blog.csdn.net)
[![Email](https://img.shields.io/badge/Email-2951256653@qq.com-cyan)](mailto:2951256653@qq.com)
......@@ -40,15 +40,15 @@ pip install tkintertools==2.6.7
### Development Version/开发版本
* Version/最新版本 : `2.6.7.dev1` (第 2 个预发布版本)
* Release/发布日期 : 2023/07/05 (UTC+08)
* Version/最新版本 : `2.6.8.dev0` (第 1 个预发布版本)
* Release/发布日期 : 2023/07/20 (UTC+08)
这个是我正在开发的版本,可能有新功能,bug 可能会比较多,但也可能会比原来的版本更加稳定。开发版没有经过多操作系统的测试,仅能保证在 Windows 系统下运行所有功能,在其他的操作系统上,可能有部分功能无法正常运行。大家可以在 Issues 中提出一些建议,我可能会适当采纳一些并在开发版本中更改或实现。
**PIP Cmd/安装命令:**
```
pip install tkintertools==2.6.7.dev1
pip install tkintertools==2.6.8.dev0
```
> **Warning**
......@@ -77,32 +77,23 @@ News/最新功能👇
### Release Notes/版本说明
**最新版本: `tkintertools-v2.6.7`**
> **Note**
> 现将开发版(`tkintertools-dev`)合并到稳定版(`tkintertools`)中,版本号格式变为 `*.*.*.dev*`,大家在通过 pip 工具进行下载时请注意!近段时间内将删除 PyPi 上的 tkintertools-dev!
> tkintertools 的介绍和使用教程均在 Wiki 中,[点我传送](https://github.com/Xiaokang2022/tkintertools/wiki)
下面是本次稳定版本(`v2.6.6` -> `v2.6.7`)的更新内容条目:
- [X] The function `rotate` of the 3D submodule adds the keyword `axis` to provide the function of rotating around the axis
3D 子模块的函数 `rotate` 新增关键字参数 `axis` 来提供绕轴旋转的功能
- [X] Added constants `ROTATE_CENTER`, `ORIGIN_COORDINATE`, `ORIGIN_SIZE`, `ORIGIN_WIDTH`, `ORIGIN_FILL` and `ORIGIN_OUTLINE`
新增常量 `ROTATE_CENTER``ORIGIN_COORDINATE``ORIGIN_SIZE``ORIGIN_WIDTH``ORIGIN_FILL``ORIGIN_OUTLINE`
- [X] Class `Tk` and `Toplevel` Added keyword arguments `alpha`, `toolwindow`, `topmost` and `transparentcolor`
`Tk``Toplevel` 新增关键字参数 `alpha``toolwindow``topmost``transparentcolor`
- [X] Fixed a bug where the class `Text` would report an error when scrolling with the mouse wheel
修复了类 `Text` 在使用鼠标滚轮滚动时会报错的 bug
- [X] Optimized the internal implementation of the functions `translate` and `scale` to improve performance
优化函数 `translate``rotate``scale` 内部的实现,提高了性能
- [X] A large number of incomplete docstrings have been modified and improved
修改和完善了大量的不完整的文档注释
- [X] Optimized some code and type hints
优化了部分代码和类型提示
- [X] Change some methods of some classes to protection methods
将部分类的部分方法更改为保护方法
- [X] Removed abstract classes and abstract methods
移除了抽象类和抽象方法
**最新版本: `tkintertools-v2.6.8.dev0`**
> **Note**
> tkintertools 的介绍、使用教程和开发文档均在 [Wiki](https://github.com/Xiaokang2022/tkintertools/wiki) 中,大家可前往查阅
下面是本次开发版本(`v2.6.7` -> `v2.6.8.dev0`)的更新内容条目:
- [X] Added class `Animation` to achieve more efficient, convenient and functional animation effects
新增类 `Animation` 来实现更加高效、更加方便和功能性更强的动画效果
- [X] Added constant `CONTROL`
新增常量 `CONTROL`
- [X] Modified the name of the constant `FRAMES` to `FPS`
修改常量 `FRAMES` 的名称为 `FPS`
- [X] The function `move` is about to be deprecated, please replace it with the new class `Animation`
函数 `move` 即将被弃用,请用新类 `Animation` 来代替
- [X] The class `Singleton` is about to be deprecated and singleton mode classes will no longer be available in subsequent releases
`Singleton` 即将被弃用,后续版本中将不再提供单例模式类
### Template Demo/模板演示
......
......@@ -18,6 +18,9 @@ TODO/待办
5. [ ] The position relationship between the space before and after the 3D object is still problematic at some point
3D 对象前后空间的位置关系在某些时候仍有问题
6. [ ] When a widget is tapped, the widgets that follow it are also triggered
点击控件时,其后面的控件也会被触发
### Features/期望功能
1. [ ] Perfect the scroll bar function of `Text` class
......
......@@ -48,7 +48,7 @@ from .__main__ import *
from .constants import *
__author__ = 'Xiaokang2022<2951256653@qq.com>'
__version__ = '2.6.7'
__version__ = '2.6.8.dev0'
__all__ = [
# Container Widgets
'Tk', 'Toplevel', 'Canvas',
......
......@@ -1382,12 +1382,98 @@ class PhotoImage(tkinter.PhotoImage):
return image
class Animation:
""" 动画 """
def __init__(
self,
widget, # type: BaseWidget | tkinter.BaseWidget | int
ms, # type: int
*,
control=CONTROL, # type: tuple[Callable[[float], float], float, float]
translation=None, # type: Iterable[float, float] | None
color=None, # type: tuple[Callable[[str], None], str, str] | None
fps=FPS, # type: int
start=None, # type: Callable | None
step=None, # type: Callable | None
stop=None, # type: Callable | None
canvas=None # type: tkinter.Canvas | None
): # type: (...) -> None
"""
`widget`: 进行动画的控件 \
`ms`: 动画总时长(单位:毫秒) \
`control`: 控制函数,为元组 (函数, 起始值, 终止值) 的形式 \
`translation`: 平移运动 \
`color`: 颜色变换 \
`fps`: 每秒帧数 \
`start`: 动画开始前执行的函数 \
`step`: 动画每一帧结束后执行的函数(包括开始和结束)\
`stop`: 动画结束后执行的函数 \
`canvas`: 当 widget 是画布中的绘制对象时,应指定 canvas
"""
self.widget = widget
self.master = canvas if isinstance(widget, int) else widget.master if isinstance(
widget, tkinter.Widget) else widget
self.start = start
self.step = step
self.stop = stop
self.translation = translation
self.color = color
self.sec = 1000 // fps # 单帧间隔时间
self.count = ms * fps // 1000 # 总帧数
if self.count == 0:
self.count = 1 # 至少一帧
self.parts = self._parts(*control)
def _parts(self, control, up, down):
# type: (Callable[[float], float], float, float) -> list[float]
""" 部分比率 """
key = (down - up) / self.count
parts = [control(key * value) for value in range(1, self.count + 1)]
total = sum(parts)
return [elem / total for elem in parts]
def _run(self, _ind=0): # type: (int) -> None
""" 执行动画 """
if _ind == self.count:
return None if self.stop is None else self.stop()
self.master.after(self.sec, self._run, _ind + 1)
if self.translation is not None:
self._translate(*[value * self.parts[_ind]
for value in self.translation])
if self.color is not None:
self.color[0](color(self.color[1:], sum(self.parts[:_ind + 1])))
None if self.step is None else self.step()
def _translate(self, dx, dy): # type: (int, int) -> None
""" 平移 """
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 控件
place_info = self.widget.place_info()
origin_x, origin_y = float(place_info['x']), float(place_info['y'])
self.widget.place(x=origin_x+dx, y=origin_y+dy)
elif isinstance(self.widget, BaseWidget): # tkintertools 控件
self.widget.move(dx, dy)
elif isinstance(self.widget, int): # tkinter._CanvasItemId
self.master.move(self.widget, dx, dy)
def run(self): # type: () -> None
""" 运行动画 """
None if self.start is None else self.start()
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
......@@ -1402,7 +1488,7 @@ def move(
times, # type: int
*,
mode, # type: Literal['smooth', 'rebound', 'flat']
frames=FRAMES, # type: int
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
......@@ -1418,7 +1504,7 @@ def move(
times, # type: int
*,
mode, # type: tuple[Callable[[float], float], float, float]
frames=FRAMES, # type: int
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
......@@ -1434,7 +1520,7 @@ def move(
*,
mode,
# type: tuple[Callable[[float], float], float, float] | Literal['smooth', 'rebound', 'flat']
frames=FRAMES, # type: int
frames=FPS, # type: int
end=None, # type: Callable | None
_ind=0 # type: int
): # type: (...) -> None
......@@ -1483,6 +1569,8 @@ def move(
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(
......
......@@ -59,12 +59,15 @@ RADIUS = 0 if SYSTEM == 'Windows' and int(
platform.version()[-5:]) < 22000 else 4
""" Default widget fillet radius """
FRAMES = 60
""" Default move frame rate """
FPS = 60
""" Default animation FPS """
TICK = '✓'
""" Default checkbox symbol """
CONTROL = lambda _: 1, 0, 1
""" Default control function """
### 3D constants ###
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册