Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小康2022
tkintertools
提交
3e377bfd
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 搜索 >>
提交
3e377bfd
编写于
10月 18, 2022
作者:
小康2022
👍
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
version pre-2.2.py
上级
109b0b70
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
3 deletion
+46
-3
tkintertools.py
tkintertools.py
+46
-3
未找到文件。
tkintertools.py
浏览文件 @
3e377bfd
...
...
@@ -5,11 +5,12 @@ tkinter 模块的扩展模块
这个模块将给用户提供可透明的、可自定义的、现代化的控件,以及一些特殊的功能函数
模块作者: 小康2022
模块版本: 2.
1
上次更新: 2022/10/
9
模块版本: 2.
2
上次更新: 2022/10/
17
---
### 可用内容
- 容器类控件: `Tk`、`Canvas`
- 工具类: `PhotoImage`
- 虚拟画布类控件: `CanvasLabel`、`CanvasButton`、`CanvasEntry`、`CanvasText`
- 处理函数: `move_widget`、`correct_text`、`process_color`
---
...
...
@@ -84,7 +85,8 @@ class Canvas(tkinter.Canvas):
`**kwargs`: 与原 tkinter 模块内 Canvas 类的参数相同
"""
tkinter
.
Canvas
.
__init__
(
self
,
master
,
width
=
width
,
height
=
height
,
**
kwargs
)
width
=
width
,
height
=
height
,
highlightthickness
=
0
,
**
kwargs
)
self
.
master
:
Tk
self
.
master
.
canvas_list
.
append
(
self
)
# 将实例添加到 Tk 的画布列表中
self
.
widget_list
:
list
[
CanvasButton
|
CanvasEntry
|
...
...
@@ -795,6 +797,47 @@ class CanvasText(_TextWidget):
self
.
cursor_update
()
# 工具类
class
PhotoImage
(
tkinter
.
PhotoImage
):
""" 图片类 """
def
__init__
(
self
,
file
:
str
|
bytes
,
gif
:
bool
=
False
,
*
args
,
**
kwargs
):
self
.
file
=
file
self
.
gif
=
gif
# 是否为动图
self
.
frames
=
[]
if
not
gif
:
return
tkinter
.
PhotoImage
.
__init__
(
self
,
file
=
file
,
*
args
,
**
kwargs
)
def
parse
(
self
,
total
:
int
,
generator
:
bool
=
False
):
""" 解析动图 """
while
(
ind
:
=
0
)
!=
total
:
image
=
tkinter
.
PhotoImage
(
file
=
self
.
file
,
format
=
'gif -index %d'
%
ind
)
ind
+=
1
if
generator
:
yield
image
else
:
self
.
frames
.
append
(
image
)
else
:
yield
self
.
frames
def
play
(
self
,
canvas
:
Canvas
,
id
,
interval
:
int
,
ind
:
int
=
0
):
""" 播放动图 """
if
self
.
gif
:
if
canvas
.
lock
:
if
ind
==
len
(
self
.
frames
):
ind
=
0
canvas
.
configure
(
id
,
image
=
self
.
frames
[
ind
])
canvas
.
after
(
interval
,
self
.
play
,
canvas
,
id
,
interval
,
ind
+
1
)
else
:
canvas
.
after
(
interval
,
self
.
play
,
canvas
,
id
,
interval
,
ind
)
# 功能函数
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录