Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小康2022
tkintertools
提交
c276bc58
tkintertools
项目概览
小康2022
/
tkintertools
10 个月 前同步成功
通知
132
Star
13
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
tkintertools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c276bc58
编写于
8月 08, 2023
作者:
小
小康2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
version 2.6.9.dev1
上级
9746028f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
157 addition
and
36 deletion
+157
-36
CHANGELOG.md
CHANGELOG.md
+15
-4
README.md
README.md
+19
-12
TODO.md
TODO.md
+6
-9
news.png
news.png
+0
-0
tkintertools/__init__.py
tkintertools/__init__.py
+5
-5
tkintertools/__main__.py
tkintertools/__main__.py
+94
-6
tkintertools/constants.py
tkintertools/constants.py
+18
-0
未找到文件。
CHANGELOG.md
浏览文件 @
c276bc58
ChangeLog/更新日志
=================
[`2.6.9.dev
0`] -2023-08-06
--------------------------
[`2.6.9.dev
1`] - 2023-08-08
--------------------------
-
### Added/新增
-
[X] Added new widget switch (
`Switch`
)
新增控件开关(
`Switch`
)
-
[X] Added widget Tip (
`ToolTip`
) and all virtual widgets added the parameter
`tooltip`
新增控件提示框(
`ToolTip`
),且所有虚拟控件新增参数
`tooltip`
-
[X] Added constants
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
and
`TOOLTIP_HIGNLIGHT_BACKGROUND
`
新增常量
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
和
`TOOLTIP_HIGNLIGHT_BACKGROUND
`
-
[X] Added constants
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
、
`TOOLTIP_HIGNLIGHT_BACKGROUND`
、
`COLOR_SWITCH_ON`
、
`COLOR_SWITCH_OFF`
、
`SWITCH_WIDTH`
、
`SWITCH_HEIGHT`
、
`SWITCH_RADIUS`
and
`SWITCH_ANIMATION_MS
`
新增常量
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
、
`TOOLTIP_HIGNLIGHT_BACKGROUND`
、
`COLOR_SWITCH_ON`
、
`COLOR_SWITCH_OFF`
、
`SWITCH_WIDTH`
、
`SWITCH_HEIGHT`
、
`SWITCH_RADIUS`
和
`SWITCH_ANIMATION_MS
`
### Fixed/修复
-
[X] Fixed an issue where the text class widget called method
`clear`
was invalid
修复了文本类控件调用方法
`clear`
无效的问题
-
[X] Fixed an issue where the class
`Animation`
automatically determined the parent widget of the widget to be moved
修复了类
`Animation`
自动确定待移动控件的父控件时出现错误的问题
### Changed/变更
-
[X] The positional parameter
`length`
of class
`CheckButton`
was renamed
`height`
类
`CheckButton`
的位置参数
`length`
更名为
`height`
### Optimized/优化
-
[X] Optimized the method
`wm_geometry`
of class
`Tk`
to accommodate some specially formatted parameters
...
...
README.md
浏览文件 @
c276bc58
...
...
@@ -9,8 +9,8 @@ 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/0
6
-orange
)
](CHANGELOG.md)
[
![ToDo
](
https://img.shields.io/badge/ToDo-1
5
-yellow
)
](TODO.md)
[
![ChangeLog
](
https://img.shields.io/badge/ChangeLog-2023/08/0
8
-orange
)
](CHANGELOG.md)
[
![ToDo
](
https://img.shields.io/badge/ToDo-1
4
-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)
...
...
@@ -40,15 +40,15 @@ pip install tkintertools==2.6.8
### Development Version/开发版本
*
Version/最新版本 :
`2.6.9.dev
0`
(第 1
个预发布版本)
*
Release/发布日期 : 2023/08/0
6
(UTC+08)
*
Version/最新版本 :
`2.6.9.dev
1`
(第 2
个预发布版本)
*
Release/发布日期 : 2023/08/0
8
(UTC+08)
这个是我正在开发的版本,可能有新功能,bug 可能会比较多,但也可能会比原来的版本更加稳定。开发版没有经过多操作系统的测试,仅能保证在 Windows 系统下运行所有功能,在其他的操作系统上,可能有部分功能无法正常运行。大家可以在 Issues 中提出一些建议,我可能会适当采纳一些并在开发版本中更改或实现。
**PIP Cmd/安装命令:**
```
pip install tkintertools==2.6.9.dev
0
pip install tkintertools==2.6.9.dev
1
```
> **Warning**
...
...
@@ -77,25 +77,31 @@ News/最新功能👇
### Release Notes/版本说明
**最新版本: `tkintertools-v2.6.9.dev
0
`**
**最新版本: `tkintertools-v2.6.9.dev
1
`**
> **Note**
> tkintertools 的介绍、使用教程和开发文档均在 [Wiki](https://github.com/Xiaokang2022/tkintertools/wiki) 中,大家可前往查阅
下面是本次开发版本(
`v2.6.8`
->
`v2.6.9.dev
0
`
)的更新内容条目:
下面是本次开发版本(
`v2.6.8`
->
`v2.6.9.dev
1
`
)的更新内容条目:
-
[X] Added new widget switch (
`Switch`
)
新增控件开关(
`Switch`
)
-
[X] Added widget Tip (
`ToolTip`
) and all virtual widgets added the parameter
`tooltip`
新增控件提示框(
`ToolTip`
),且所有虚拟控件新增参数
`tooltip`
-
[X] Added constants
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
and
`TOOLTIP_HIGNLIGHT_BACKGROUND
`
新增常量
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
和
`TOOLTIP_HIGNLIGHT_BACKGROUND
`
-
[X] Added constants
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
、
`TOOLTIP_HIGNLIGHT_BACKGROUND`
、
`COLOR_SWITCH_ON`
、
`COLOR_SWITCH_OFF`
、
`SWITCH_WIDTH`
、
`SWITCH_HEIGHT`
、
`SWITCH_RADIUS`
and
`SWITCH_ANIMATION_MS
`
新增常量
`DURATION`
、
`TOOLTIP_FG`
、
`TOOLTIP_BG`
、
`TOOLTIP_HIGNLIGHT_THICKNESS`
、
`TOOLTIP_HIGNLIGHT_BACKGROUND`
、
`COLOR_SWITCH_ON`
、
`COLOR_SWITCH_OFF`
、
`SWITCH_WIDTH`
、
`SWITCH_HEIGHT`
、
`SWITCH_RADIUS`
和
`SWITCH_ANIMATION_MS
`
-
[X] Fixed an issue where the text class widget called method
`clear`
was invalid
修复了文本类控件调用方法
`clear`
无效的问题
-
[X] Fixed an issue where the class
`Animation`
automatically determined the parent widget of the widget to be moved
修复了类
`Animation`
自动确定待移动控件的父控件时出现错误的问题
-
[X] The positional parameter
`length`
of class
`CheckButton`
was renamed
`height`
类
`CheckButton`
的位置参数
`length`
更名为
`height`
-
[X] Optimized the method
`wm_geometry`
of class
`Tk`
to accommodate some specially formatted parameters
优化了类
`Tk`
的方法
`wm_geometry`
以适应某些特殊格式的参数
### Template Demo/模板演示
下面是一个主要新功能的示例程序,
当按照示例代码方式给虚拟控件传入一个名为
`tooltip`
的参数之后,便可以让这个控件拥有提示框
下面是一个主要新功能的示例程序,
即新增控件:开关!这个控件可以调整长宽、颜色、以及圆角的大小!
下面是示例程序的效果图(运行环境为 Windows11-Python3.11.4):
...
...
@@ -106,8 +112,9 @@ News/最新功能👇
```
python
# 此处只展示核心代码
tip
=
tkt
.
ToolTip
(
'模块介绍
\n
ToolTip 测试'
)
tkt
.
Button
(
canvas
,
10
,
660
,
200
,
50
,
text
=
'Doc'
,
tooltip
=
tip
)
tkt
.
Switch
(
canvas
,
540
,
420
)
# 默认样式
tkt
.
Switch
(
canvas
,
610
,
420
,
radius
=
4
,
default
=
True
)
# 圆角半径 4 像素,默认开
tkt
.
Switch
(
canvas
,
680
,
420
,
radius
=
0
)
# 无圆角
```
</details>
...
...
TODO.md
浏览文件 @
c276bc58
...
...
@@ -29,23 +29,20 @@ TODO/待办
2.
[ ] Perfection and optimization of zoom function
对缩放功能的完善和优化
3.
[ ] Try adding a new widget:
`Switch`
尝试新增控件:开关 (
`Switch`
)
4.
[ ] Try adding support for some MarkDown syntax
3.
[ ] Try adding support for some MarkDown syntax
尝试增加对部分 Markdown 语法的支持
5
.
[ ] Try adding a new pattern of no progress to the
`Progressbar`
widget
4
.
[ ] Try adding a new pattern of no progress to the
`Progressbar`
widget
尝试为进度条控件增加无进度的新模式
6
.
[ ] Implement symmetry in 3D modules
5
.
[ ] Implement symmetry in 3D modules
实现 3D 模块中的对称功能
7
.
[ ] Enhanced projection functionality in 3D modules
6
.
[ ] Enhanced projection functionality in 3D modules
增强 3D 模块中的投影功能
8
.
[ ] Add more 3D spatial geometry classes
7
.
[ ] Add more 3D spatial geometry classes
增加更多 3D 空间几何体类
9
.
[ ] Add lights and achieve simple light and shadow renderings
8
.
[ ] Add lights and achieve simple light and shadow renderings
添加光源,并实现简单的光影渲染的效果
news.png
查看替换文件 @
9746028f
浏览文件 @
c276bc58
110.0 KB
|
W:
|
H:
30.4 KB
|
W:
|
H:
2-up
Swipe
Onion skin
tkintertools/__init__.py
浏览文件 @
c276bc58
...
...
@@ -26,9 +26,9 @@ Provides
Contents
--------
* Container Widgets: `Tk`, `Toplevel`, `Canvas`
* Virtual Canvas Widgets: `Label`, `Button`, `CheckButton`, `Entry`, `Text`, `Progressbar`
* Tool Classes: `PhotoImage`, `ToolTip`, `Singleton`, `Animation`
* Virtual Canvas Widgets: `Label`, `Button`, `CheckButton`, `Entry`, `Text`, `Progressbar`,`ToolTip`, `Switch`
* Tool Functions: `move`, `text`, `color`, `askfont`, `SetProcessDpiAwareness`
* Tool Classes: `PhotoImage`, `Singleton`, `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.dev
0
'
__version__
=
'2.6.9.dev
1
'
__all__
=
[
# Container Widgets
'Tk'
,
'Toplevel'
,
'Canvas'
,
# Virtual Canvas Widgets
'Label'
,
'Button'
,
'CheckButton'
,
'Entry'
,
'Text'
,
'Progressbar'
,
'Label'
,
'Button'
,
'CheckButton'
,
'Entry'
,
'Text'
,
'Progressbar'
,
'ToolTip'
,
'Switch'
,
# Tool Classes
'PhotoImage'
,
'
ToolTip'
,
'
Singleton'
,
'Animation'
,
'PhotoImage'
,
'Singleton'
,
'Animation'
,
# Tool Functions
'move'
,
'text'
,
'color'
,
'askfont'
,
'SetProcessDpiAwareness'
,
]
+
all_constants
tkintertools/__main__.py
浏览文件 @
c276bc58
...
...
@@ -175,6 +175,15 @@ class Toplevel(tkinter.Toplevel, Tk):
self
.
focus_set
()
# 把焦点转移到该子窗口上来
class
CombinedItem
(
list
):
""" 画布元素组合体 """
def
__init__
(
self
,
*
args
):
# type: (int) -> None
if
not
all
(
map
(
lambda
_
:
isinstance
(
_
,
int
),
args
)):
raise
TypeError
(
'Not all elements are of type _CanvasItemId'
)
list
.
__init__
(
self
,
args
)
class
Canvas
(
tkinter
.
Canvas
):
""" 画布容器类 """
...
...
@@ -987,7 +996,7 @@ class CheckButton(Button):
canvas
,
# type: Canvas
x
,
# type: int
y
,
# type: int
length
,
# type: int
height
,
# type: int
*
,
radius
=
RADIUS
,
# type: float
text
=
''
,
# type: str
...
...
@@ -1001,14 +1010,14 @@ class CheckButton(Button):
color_outline
=
COLOR_BUTTON_OUTLINE
# type: tuple[str, str, str]
):
# type: (...) -> None
Button
.
__init__
(
self
,
canvas
,
x
,
y
,
length
,
length
,
radius
=
radius
,
borderwidth
=
borderwidth
,
image
=
image
,
self
,
canvas
,
x
,
y
,
height
,
height
,
radius
=
radius
,
borderwidth
=
borderwidth
,
image
=
image
,
tooltip
=
tooltip
,
color_text
=
color_text
,
color_fill
=
color_fill
,
color_outline
=
color_outline
)
if
justify
==
'right'
:
self
.
_text
=
canvas
.
create_text
(
x
+
1.25
*
length
,
y
+
length
/
2
,
text
=
text
,
anchor
=
'w'
)
x
+
1.25
*
height
,
y
+
height
/
2
,
text
=
text
,
anchor
=
'w'
)
else
:
self
.
_text
=
canvas
.
create_text
(
x
-
0.25
*
length
,
y
+
length
/
2
,
text
=
text
,
anchor
=
'e'
)
x
-
0.25
*
height
,
y
+
height
/
2
,
text
=
text
,
anchor
=
'e'
)
self
.
command
=
lambda
:
self
.
set
(
not
bool
(
self
.
value
))
if
value
:
self
.
command
()
...
...
@@ -1311,6 +1320,85 @@ class Progressbar(BaseWidget):
self
.
configure
(
text
=
'%.2f%%'
%
(
percentage
*
100
))
class
Switch
:
""" 开关 """
def
__init__
(
self
,
canvas
,
# type: Canvas
x
,
# type: int
y
,
# type: int
width
=
SWITCH_WIDTH
,
# type: int
height
=
SWITCH_HEIGHT
,
# type: int
*
,
radius
=
SWITCH_RADIUS
,
# type: float
borderwidth
=
BORDERWIDTH
,
# type: int
tooltip
=
None
,
# type: ToolTip | None
color_fill
=
COLOR_SWITCH_OFF
,
# type: tuple[str, str, str]
color_outline
=
COLOR_BUTTON_OUTLINE
,
# type: tuple[str, str, str]
default
=
False
,
# type: bool
on
=
None
,
# type: Callable | None
off
=
None
,
# type: Callable | None
):
# type: (...) -> None
"""
`canvas`: 父画布控件 \
`x`: 横坐标 \
`y`: 纵坐标 \
`width`: 宽度 \
`height`: 高度 \
`radius`: 圆角半径 \
`borderwidth`: 边框宽度 \
`tooltip`: 提示框 \
`color_fill`: 内部颜色 \
`color_outline`: 边框颜色 \
`default`: 默认值 \
`on`: 转换到开时触发的回调函数 \
`off`: 转换到关时触发的回调函数
"""
self
.
value
=
default
self
.
width
=
height
*
2
if
width
<
height
*
2
else
width
self
.
height
=
height
self
.
on
=
on
self
.
off
=
off
self
.
outside
=
Button
(
canvas
,
x
,
y
,
self
.
width
,
height
,
radius
=
radius
,
borderwidth
=
borderwidth
,
tooltip
=
tooltip
,
color_fill
=
color_fill
,
color_outline
=
color_outline
,
command
=
lambda
self
=
self
:
self
.
set
(
not
self
.
value
))
spcaing
=
height
*
2
/
15
self
.
inside
=
Label
(
canvas
,
x
+
spcaing
,
y
+
spcaing
,
height
-
spcaing
*
2
,
height
-
spcaing
*
2
,
radius
=
radius
,
borderwidth
=
borderwidth
,
color_outline
=
(
'#333'
,)
*
3
,
color_fill
=
(
'black'
,)
*
3
)
if
self
.
value
is
True
:
self
.
_animate
(
0
)
def
_animate
(
self
,
ms
=
SWITCH_ANIMATION_MS
):
# type: (int) -> None
""" 移动动画 """
if
self
.
value
:
key
=
1
self
.
outside
.
configure
(
color_fill
=
COLOR_SWITCH_ON
,
color_outline
=
COLOR_SWITCH_ON
)
else
:
key
=
-
1
self
.
outside
.
configure
(
color_fill
=
COLOR_SWITCH_OFF
,
color_outline
=
COLOR_BUTTON_OUTLINE
)
self
.
outside
.
state
()
Animation
(
self
.
inside
,
ms
,
fps
=
90
,
control
=
(
math
.
sin
,
0
,
math
.
pi
),
translation
=
(
key
*
(
self
.
width
-
self
.
height
)
*
self
.
inside
.
master
.
rx
,
0
)).
run
()
def
get
(
self
):
# type: () -> bool
""" 返回状态 """
return
self
.
value
def
set
(
self
,
value
):
# type: (bool) -> None
""" 设定状态 """
self
.
value
=
value
if
self
.
value
and
self
.
on
is
not
None
:
self
.
on
()
if
not
self
.
value
and
self
.
off
is
not
None
:
self
.
off
()
self
.
_animate
()
class
ToolTip
:
""" 提示框 """
...
...
@@ -1528,8 +1616,8 @@ class Animation:
`loop`: 是否循环播放动画,默认不循环,循环时参数 stop 失效
"""
self
.
widget
=
widget
self
.
master
=
canvas
if
isinstance
(
widget
,
int
)
else
widget
.
master
if
isinstance
(
widget
,
tkinter
.
Widget
)
else
widget
self
.
master
=
canvas
if
isinstance
(
widget
,
int
)
else
widget
if
isinstance
(
widget
,
tkinter
.
Widget
)
else
widget
.
master
self
.
start
=
start
self
.
step
=
step
self
.
stop
=
stop
...
...
tkintertools/constants.py
浏览文件 @
c276bc58
...
...
@@ -36,6 +36,12 @@ COLOR_NONE = '', '', '', ''
COLOR_BAR
=
'#E1E1E1'
,
'#06b025'
""" Default progress bar color """
COLOR_SWITCH_ON
=
'#288CDB'
,
'#3E98DF'
,
'#4884B4'
,
'#E0E0E0'
""" Default color when `Switch` is on """
COLOR_SWITCH_OFF
=
COLOR_BUTTON_FILL
""" Default color when `Switch` is off """
### Other constants ###
...
...
@@ -83,6 +89,18 @@ TOOLTIP_HIGNLIGHT_THICKNESS = 1
TOOLTIP_HIGNLIGHT_BACKGROUND
=
'black'
""" Default ToolTip highlightbackground """
SWITCH_WIDTH
=
0
""" Default Switch width """
SWITCH_HEIGHT
=
30
""" Default Switch height """
SWITCH_RADIUS
=
float
(
'inf'
)
""" Default Switch radius """
SWITCH_ANIMATION_MS
=
250
""" Default animation duration of the Switch """
### 3D constants ###
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录