An auxiliary module of the tkinter module.
Project description
🚀tkintertools🚀
tkintertools
模块是 tkinter
模块的一个辅助模块
The tkintertools
module is an auxiliary module of the tkinter
module
Install/模块安装👇
Stable Version/稳定版本
- Version/最新版本 :
2.6.8
- Release/发布日期 : 2023/08/03 (UTC+08)
这个是目前的最新稳定版,相对于开发版本而言比较稳定,bug 大体上是没有那么多的,推荐使用这个。稳定版和开发版相比,它在发布之前有个测试的步骤,经过测试之后(各项功能正常运行,多平台兼容)才会发布。
PIP Cmd/安装命令:
pip install tkintertools==2.6.8
Development Version/开发版本
- Version/最新版本 :
2.6.8.dev1
(第 2 个预发布版本) - Release/发布日期 : 2023/07/28 (UTC+08)
这个是我正在开发的版本,可能有新功能,bug 可能会比较多,但也可能会比原来的版本更加稳定。开发版没有经过多操作系统的测试,仅能保证在 Windows 系统下运行所有功能,在其他的操作系统上,可能有部分功能无法正常运行。大家可以在 Issues 中提出一些建议,我可能会适当采纳一些并在开发版本中更改或实现。
PIP Cmd/安装命令:
pip install tkintertools==2.6.8.dev1
Warning
开发版仅作示例,各函数或类的 API 并非最终确定结果,直接使用开发版可能导致后续无法与稳定版兼容!
若不指定具体的版本号,则会下载最新的稳定版本,也就是说,开发版本只能通过指定的版本号获取!
Requirements/环境需求
目前 稳定版 在以下操作系统中已经测试通过:
可能还有其他的操作系统也是可以运行 tkintertools 的,我没有进行更多的验证。
没有任何额外的依赖包(除了一般 Python 内置的 tkinter),但只支持以下 Python 版本:
News/最新功能👇
Release Notes/版本说明
最新版本: tkintertools-v2.6.8
Note
tkintertools 的介绍、使用教程和开发文档均在 Wiki 中,大家可前往查阅
下面是本次开发版本(v2.6.7
-> v2.6.8
)的更新内容条目:
- If the user's Python includes a PIL library, PIL is automatically invoked when autoscaling images to extend the functionality of the class
PhotoImage
若使用者的 Python 包含有 PIL 库,则在自动缩放图片时自动调用 PIL 来扩展类PhotoImage
的功能 - Added class
Animation
to achieve more efficient, convenient and functional animation effects
新增类Animation
来实现更加高效、更加方便和功能性更强的动画效果 - Added constant
CONTROL
新增常量CONTROL
- Fixed the bug that widgets
Entry
andText
would report an error when pasting text
修复控件Entry
和Text
粘贴文本时会报错的 bug - Modified the name of the constant
FRAMES
toFPS
修改常量FRAMES
的名称为FPS
- The parameter
precision
of the methodzoom
of classPhotoImage
was changed from positional argument to keyword argument
类PhotoImage
的方法zoom
的参数precision
由位置参数变更为关键字参数 - The function
move
is about to be deprecated, please replace it with the new classAnimation
函数move
即将被弃用,请用新类Animation
来代替 - The class
Singleton
is about to be deprecated and singleton mode classes will no longer be available in subsequent releases
类Singleton
即将被弃用,后续版本中将不再提供单例模式类
Template Demo/模板演示
下面是一个主要新功能的示例程序,运行下面的示例程序时,其拥有以下功能:
- 效果与之前版本相同,但是代码量更少!
- 按住鼠标左键拖动可以旋转这多个几何体;
- 按住鼠标右键拖动可以移动这些几何体在空间中的位置;
- 滚动鼠标中键可以放大和缩小画面;
- 这多个几何体会自动地旋转以及上下浮动;
下面是示例程序的效果图(运行环境为 Windows11-Python3.11.4):
CODE/源代码
import math # 数学支持
import tkintertools as tkt # 引入基础模块
from tkintertools import tools_3d as t3d # 引入 3d 子模块
root = tkt.Tk('3D', 1280, 720) # 创建窗口
space = t3d.Space(root, 1280, 720, 0, 0) # 创建空间
for a in -100, 0, 100:
for b in -100, 0, 100:
for c in -100, 0, 100:
t3d.Cuboid(space, a-50, b-50, c-50, 100, 100, 100, # 创建正方体
color_up='white', color_down='yellow', color_left='red',
color_right='orange', color_front='blue', color_back='green')
def animate(value=[0]): # type: (list[int]) -> None
""" 动画 """
for geo in space.geos():
geo.rotate(dz=0.01)
geo.translate(dz=math.sin(value[0]))
geo.update()
value[0] += math.pi/60
space.space_sort()
def scale(event):
""" 缩放事件 """
k = 1.05 if event.keysym == 'equal' else 0.95 if event.keysym == 'minus' else 1 # 缩放比率
for geo in space.geos(): # 遍历所有的几何体(不包括基本 3D 对象)
geo.scale(k, k, k) # 缩放
geo.update() # 更新改对象的实际画面
space.space_sort() # 空间前后位置排序
tkt.Animation(space, 1000, callback=lambda _: animate(), loop=True).run() # 调用类 Animation
root.bind('<Key-equal>', scale) # 绑定等号按键
root.bind('<Key-minus>', scale) # 绑定减号按键
root.mainloop() # 消息事件循环
More/更多👇
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tkintertools-2.6.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d09e16bbe22fae12eea3e9be57cf9a567c47a2091f96a67fb5b84e2f88cc5982 |
|
MD5 | 9ff5fae09f5996567daeaf48bbac36b1 |
|
BLAKE2b-256 | f66d780366d1443a8ca459853666e3f0f710a609c7edd4d64d70ab2ce64729af |