Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小康2022
tkintertools
提交
70315bf5
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 搜索 >>
提交
70315bf5
编写于
3月 12, 2023
作者:
小康2022
👍
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
version 2.5.10.4
上级
d2ad9d71
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
14 deletion
+23
-14
README.md
README.md
+7
-4
test.py
test.py
+12
-5
tkintertools.py
tkintertools.py
+4
-5
未找到文件。
README.md
浏览文件 @
70315bf5
...
...
@@ -5,8 +5,8 @@
Update/最近更新
--------------
> Version: 2.5.10.
3
> Date: 2023/0
2/11
> Version: 2.5.10.
4
> Date: 2023/0
3/12
### Features/新增
...
...
@@ -29,6 +29,9 @@ Update/最近更新
-
[X] Optimize the solution to the adaptive DPI problem
优化解决适配 DPI 问题的方案
-
[X] Optimized the way font size fits DPI
优化了字体大小适配 DPI 的方式
> 更多信息见更新日志: [CHANGELOG](./CHANGELOG.md)
Description/模块描述
...
...
@@ -85,8 +88,8 @@ The `tkintertools` module is an auxiliary module of the `tkinter` module
*
`Compatible Version`
folder contains the latest compatible version, which is compatible with python 3.7
`Compatible Version`
文件夹里面是当前最新版本的兼容版本,可兼容python3.7版本
> 兼容版本: [Compatible Version](./Compatible%20Version/)
过去版本:
[
Release Version
](
./Release%20Version/
)
> 兼容版本: [Compatible Version](./Compatible%20Version/)
>
过去版本: [Release Version](./Release%20Version/)
### More/更多
...
...
test.py
浏览文件 @
70315bf5
...
...
@@ -4,12 +4,12 @@
import
sys
if
sys
.
version_info
<
(
3
,
11
):
raise
RuntimeError
(
'
\033
[31mPython
版本低于3.10,无法运行测试程序
!
\033
[0m'
)
raise
RuntimeError
(
'
\033
[31mPython
version is too low
!
\033
[0m'
)
from
math
import
cos
,
pi
from
random
import
randint
from
tkinter
import
TclError
,
messagebox
from
tkinter
import
Menu
,
TclError
,
messagebox
from
winsound
import
Beep
import
tkintertools
as
tkt
...
...
@@ -55,9 +55,10 @@ def shutdown() -> None:
root
.
quit
()
# 退出测试程序
tkt
.
SetProcessDpiAwareness
()
root
=
tkt
.
Tk
(
'测试程序'
,
1280
,
720
,
shutdown
=
shutdown
)
root
=
tkt
.
Tk
(
'tkintertools - 测试程序'
,
1280
,
720
,
shutdown
=
shutdown
)
root
.
minsize
(
640
,
360
)
menu
=
Menu
(
root
,
tearoff
=
False
)
root
.
configure
(
menu
=
menu
)
canvas_main
=
tkt
.
Canvas
(
root
,
1280
,
720
)
canvas_main
.
place
(
x
=
0
,
y
=
0
)
canvas_doc
=
tkt
.
Canvas
(
root
,
1280
,
720
)
...
...
@@ -69,6 +70,11 @@ canvas_graph.place(x=1280, y=0)
def
sound
():
return
Beep
(
600
,
100
)
m
=
Menu
(
menu
,
tearoff
=
False
)
menu
.
add_cascade
(
menu
=
m
,
label
=
'帮助(H)'
)
m
.
add_command
(
label
=
'关于'
,
accelerator
=
'Ctrl+A'
)
tkt
.
CanvasButton
(
canvas_main
,
10
,
660
,
200
,
50
,
0
,
'模块文档'
,
command
=
lambda
:
(
tkt
.
move
(
root
,
canvas_main
,
1280
*
canvas_main
.
rate_x
,
0
,
500
,
'rebound'
),
...
...
@@ -127,7 +133,7 @@ load.command_ex['press'] = sound
bar
=
tkt
.
ProcessBar
(
canvas_main
,
320
,
320
,
640
,
35
)
canvas_doc
.
create_text
(
# 模块说明文档
15
,
360
,
text
=
tkt
.
__doc__
,
font
=
tkt
.
font
(
'consolas'
,
17
,
'italic'
),
anchor
=
'w'
)
15
,
360
,
text
=
tkt
.
__doc__
,
font
=
(
'consolas'
,
16
,
'italic'
),
anchor
=
'w'
)
try
:
# 加载图片
canvas_graph
.
create_image
(
...
...
@@ -135,4 +141,5 @@ try: # 加载图片
except
TclError
:
# 缺少图片
print
(
'
\033
[31m缺少示例图片tkinter.png
\033
[0m'
)
tkt
.
SetProcessDpiAwareness
()
root
.
mainloop
()
# 消息事件循环
tkintertools.py
浏览文件 @
70315bf5
...
...
@@ -42,7 +42,7 @@ from fractions import Fraction # 图片缩放
from
typing
import
Generator
,
Iterable
,
Literal
,
Self
,
Type
# 类型提示
__author__
=
'Xiaokang2022'
__version__
=
'2.5.10.
3
'
__version__
=
'2.5.10.
4
'
__all__
=
[
'Tk'
,
'Toplevel'
,
...
...
@@ -73,9 +73,8 @@ COLOR_BAR = '#E1E1E1', '#06b025' # 默认的
BORDERWIDTH
=
1
# 默认控件外框宽度
CURSOR
=
'│'
# 文本光标
FONT
=
'楷体'
# 默认字体
_SIZE
=
24
# 默认字体大小
SIZE
=
round
(
_SIZE
/
SCALE
)
# 默认字体大小(适配DPI)
FONT
=
'楷体'
# 默认字体
SIZE
=
24
# 默认字体大小
LIMIT
=
-
1
# 默认文本长度
RADIUS
=
0
# 默认控件圆角半径
FRAMES
=
60
# 默认帧数
...
...
@@ -1384,7 +1383,7 @@ def color(
return
'#%06X'
%
_rgb
def
font
(
family
:
str
=
FONT
,
size
:
int
=
_
SIZE
,
*
args
:
str
)
->
tuple
:
def
font
(
family
:
str
=
FONT
,
size
:
int
=
SIZE
,
*
args
:
str
)
->
tuple
:
"""
### 字体函数
字体大小将自动适配 DPI 级别
\n
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录