tkintertools-test


Nametkintertools-test JSON
Version 3 PyPI version JSON
download
home_pagehttps://gitcode.net/weixin_62651706/tkintertools
SummaryAn auxiliary module of the tkinder module
upload_time2023-03-28 05:01:03
maintainer
docs_urlNone
authorXiaokang2022
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
    <h1>🚀<b>tkintertools</b>🚀</h1>
    <img height="120px" alt="logo.png" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/tkintertools.png"/>
    <p>The <code>tkintertools</code> module is an auxiliary module of the <code>tkinter</code> module</p>
    <p><code>tkintertools</code> 模块是 <code>tkinter</code> 模块的辅助模块</p>
    <img src="https://img.shields.io/badge/Version-2.6.0-blue" alt="latest version" />
    <a href="./LICENSE">
        <img src="https://img.shields.io/badge/License-Mulan PSL v2-green" alt="License" />
    </a>
    <a href="./CHANGELOG.md">
        <img src="https://img.shields.io/badge/ChangeLog-2023/03/28-orange" alt="CHANGELOG" />
    </a>
    <a href="./TODO.md">
    <img src="https://img.shields.io/badge/ToDo-5-yellow" alt="TODO" />
    </a>
    <br>
    <img src="https://img.shields.io/badge/Mail-2951256653@qq.com-purple" alt="Contact" />
    <a href="https://xiaokang2022.blog.csdn.net">
        <img src="https://img.shields.io/badge/Blog-https://xiaokang2022.blog.csdn.net-red" alt="Blog" />
    </a>
</div>

🚀Installation/模块安装
-----------------------

### 👉Stable version/稳定版本

* Version/版本 : 2.6.0
* Release Date/发布日期 : 2023/03/28

```
pip install tkintertools==2.6.0
```

### 👉Development version/开发版本

* Version/版本 : 2.6.0
* Release Date/发布日期 : 2023/03/20

```
pip install tkintertools-dev==2.6.0
```

🚀Description/模块说明
----------------------

`tkintertools` 是一个完全没有使用任何第三方模块和库的Python界面开发模块,同时,它也没有任何依赖包,它的功能完全由内置模块和函数实现。

`tkintertools` 是一款基于 `tkinter` 模块的二次开发的界面编程模块,它和 `tkinter` 最大的不同在于,它的控件并非真实的控件,而是在 `tkinter` 模块中 `Canvas` 对象中绘制而成的,这就赋予了 `tkintertools` 控件一些特性,列举如下:

1. 控件背景可以是透明的👍
2. 控件的样式可以是自定义的👍
3. 控件的创建速度是远大于 `tkinter` 的控件的👍

开发 `tkintertools` 模块选用的 Python 版本为 3.10,在这个及以上版本的 Python 拥有很好的类型提示语法,能为用户提供最好的语法提示。这里没有选择用 .pyi 存根文件的方式来实现类型提示的功能,主要原因是 .pyi 文件不方便和模块真正的文件进行同步修改,而且既然这个类型提示的功能在 Python3.6(Python3.10 的类型提示语法得到进一步强化) 以上在源代码中实现,那何必再用存根文件呢?

使用 Python3.10 强化了的类型提示语法也意味着用户使用的 Python 版本也必须至少为 3.10,为了弥补兼容性,后续会推出兼容版的 tkintertools。目前需要兼容的用户,可以在源代码中自行修改,需要修改的语法如下:

3.9 及更低版本 : 类型提示语法中的 “|”,isinstance 函数中的 “|”  
3.7 及更低版本 : 赋值运算符的海象运算符 “:=”  
3.6 及更低版本 : `fractions` 模块 `Fraction` 类的 `limit_denominator` 方法(建议升级Python版本)  
3.5 及更低版本 : 全部的类型提示语法(建议升级Python版本)

🚀Provides/模块功能
-------------------

Here, only the more distinctive features will be listed  
这里只会列举出比较具有特色的功能

### ⭐Customizable widgets/可自定义的控件

### ⭐Automatically control size/自动控制大小

### ⭐Easily move widgets/轻松移动控件

### ⭐Gradient colors/渐变色

### ⭐Automatically adapt to DPI/自动适应DPI

### ⭐Scalable Picture/可缩放图片

### ⭐Detailed type tips/详细的类型提示

🚀Contents/模块内容
-------------------

Each non internal class and function in the module will be described in detail here  
这里会详细说明模块中的每个非内部类和函数

### ⭐Container Widget/容器控件

1. `Tk` : 窗口类

    继承于 `tkinter.Tk`,在继承了 `tkinter` 模块内 `Tk` 的基础上,又加入了对 `tkintertools` 模块中的 `Canvas` 对象的支持,并加入了检测窗口大小是否缩放的机制,以使得其子 `Canvas` 均能正确地进行缩放

2. `Toplevel` : 顶级窗口类

    继承于 `tkinter.Toplevel` 和 `Tk`,加入了对 `tkintertools` 模块中的 `Canvas` 对象的支持,其余均与 `Tk` 一样

3. `Canvas` : 画布类

    继承于 `tkinter.Canvas`,加入了对画布虚拟控件的支持,同时是各类响应事件、缩放控制的管理者,也对 `tkinter.Canvas` 的实例方法有一定的兼容性

### ⭐Virtual Canvas Widget/虚拟画布控件

1. `Label` : 标签控件

    标签控件的功能和 `tkinter.Label` 的功能类似,但更加的多元化  
    下面是 `Label` 控件的外观:  
    <img width="720px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/LabelTest.png" alt="LabelTest.png" />

    ```python
    """ Label Test """

    import tkintertools as tkt

    root = tkt.Tk('LabelTest', 1000, 400)
    canvas = tkt.Canvas(root, 1000, 400)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#0000FF'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)


    colorful(510, 175, 480, 150)

    tkt.Label(canvas, 50, 50, 400, 100, 0, 'NormalLabel\nHere is the text')
    tkt.Label(canvas, 50, 200, 400, 100, 20, 'RoundCornerLabel')
    tkt.Label(canvas, 550, 50, 400, 100, 0, 'DisableLabel').set_live(False)
    tkt.Label(canvas, 550, 200, 400, 100, 20,
            'TransparentLabel', color_fill=tkt.COLOR_NONE)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

2. `Button` : 按钮控件

    按钮控件相较于 `tkinter.Button` ,其自由度更高,`tkinter.Button` 只有在按下的时候才能触发绑定的关联事件,而 `Button` 却可以在鼠标移至按钮上方时、鼠标按下时、鼠标松开时都可以绑定关联事件  
    下面是 `Button` 控件的外观:  
    <img width="360px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ButtonTest.png" alt="ButtonTest.png" />

    ```python
    """ Button Test """

    import tkintertools as tkt

    root = tkt.Tk('ButtonTest', 500, 500)
    canvas = tkt.Canvas(root, 500, 500)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#0000FF'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)


    colorful(50, 280, 400, 100)

    tkt.Button(canvas, 150, 135, 200, 50, 0, 'NormalButton')
    tkt.Button(canvas, 100, 195, 300, 50, 10, 'RoundCornerButton')
    tkt.Button(canvas, 150, 255, 200, 50, 0, 'DisableButton').set_live(False)
    tkt.Button(canvas, 100, 315, 300, 50, 10,
            'TransparentButton', color_fill=tkt.COLOR_NONE)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

3. `CheckButton` : 复选框控件

4. `Entry` : 输入框控件

    输入框控件可以轻松地设置输入的文本位置(靠左、居中和靠右),同时,它可以在鼠标移至输入框上方、鼠标未在输入框上方两种状态显示不同的默认文本  
    下面是 `Entry` 控件的外观:  
    <img width="360px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/EntryTest.png" alt="EntryTest.png" />
    
    ```python
    """ Entry Test """

    import tkintertools as tkt

    root = tkt.Tk('EntryTest', 500, 400)
    canvas = tkt.Canvas(root, 500, 400)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#0000FF'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)


    colorful(50, 193, 400, 100)
    tkt.Entry(canvas, 20, 20, 200, 30, 0, ('LeftEntry', 'Enter'))
    tkt.Entry(canvas, 20, 55, 200, 30, 0,
            ('CenterEntry', 'Enter'), justify='center')
    tkt.Entry(canvas, 20, 90, 200, 30, 0, ('RightEntry', 'Enter'), justify='right')
    tkt.Entry(canvas, 270, 20, 200, 30, 8, 'LeftEntry')
    tkt.Entry(canvas, 270, 55, 200, 30, 8, 'CenterEntry', justify='center')
    tkt.Entry(canvas, 270, 90, 200, 30, 8, 'RightEntry', justify='right')

    tkt.Entry(canvas, 100, 150, 300, 35, 0,
            ('PasswordEntry', 'Click To Enter'), justify='center', show='•')
    tkt.Entry(canvas, 100, 200, 300, 35, 0, 'DisableEntry',
            justify='center').set_live(False)
    tkt.Entry(canvas, 100, 250, 300, 35, 0, 'TransparentEntry',
            justify='center', color_fill=tkt.COLOR_NONE)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

5. `Text` : 文本框控件

    文本框类似于输入框,这里就不再赘述  
    下面是 `Text` 控件的外观:  
    <img width="720px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/TextTest.png" alt="TextTest.png" />

    ```python
    """ Text Test """

    import tkintertools as tkt

    root = tkt.Tk('TextTest', 1000, 400)
    canvas = tkt.Canvas(root, 1000, 400)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#0000FF'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)


    colorful(510, 175, 480, 150)

    tkt.Text(canvas, 50, 50, 400, 100, 0, ('NormalText(Left)', 'Click To Enter'))
    tkt.Text(canvas, 50, 200, 400, 100, 20,
            'RoundCornerText(Center)', justify='center')
    tkt.Text(canvas, 550, 50, 400, 100, 0, 'DisableText').set_live(False)
    tkt.Text(canvas, 550, 200, 400, 100, 20,
            'TransparentText(Right)', justify='right', color_fill=tkt.COLOR_NONE)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

6. `Progressbar` : 进度条控件

    进度条控件相比 `tkinter.ttk.Progressbar`,外观上的自由度较大  
    下面是 `Progressbar` 控件的外观:  
    <img width="360px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ProgressbarTest.png" alt="ProgressbarTest.png" />

    ```python
    """ Progressbar Test """

    import tkintertools as tkt

    root = tkt.Tk('ProgressbarTest', 500, 500)
    canvas = tkt.Canvas(root, 500, 500)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#0000FF'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)


    colorful(30, 290, 440, 50)

    tkt.Progressbar(canvas, 50, 50, 400, 30)
    tkt.Progressbar(canvas, 50, 100, 400, 30).load(.6667)
    tkt.Progressbar(canvas, 50, 150, 400, 30, 5).load(1)
    (_ := tkt.Progressbar(canvas, 50, 200, 400, 30)).load(0.3333)
    _.set_live(False)
    tkt.Progressbar(canvas, 50, 250, 400, 30, color_bar=(
        'lightyellow', 'skyblue')).load(.5)
    tkt.Progressbar(canvas, 50, 300, 400, 30, color_bar=('', 'orange')).load(.1667)

    progressbar = tkt.Progressbar(canvas, 50, 375, 400, 30)
    progressbar_2 = tkt.Progressbar(canvas, 50, 425, 400, 30)


    def load(total: int, count: int = 0) -> None:
        """ load progressbar """
        progressbar.load(count/total)
        progressbar_2.load(1-count/total)
        if count < total:
            root.after(3, load, total, count+1)


    load(10000)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

### ⭐Tool Class/工具类

1. `PhotoImage` : 图片类

    `PhotoImage` 类继承于 `tkinter.PhotoImage`,它是在 `tkinter.PhotoImage` 的基础上做功能的强化,对 gif 动图有很好的支持,仅需极少量代码即可实现动图的显示,还可以设置动图显示的速度,此外,对 png 类型的图片的支持也有强化,可以在不依赖任何第三方模块或者库的情况下,对图片进行缩放

2. `Singleton` : 单例模式类

    单例模式,不用介绍了吧?通过继承它来使用

### ⭐Tool Function/工具函数

1. `move` : 移动函数

    移动函数可以轻松地按一定的规律、移动速度、移动时间去移动 `tkintertools` 模块内的所有对象,同时兼容了 `tkinter` 内的对象,即 `tkinter` 中的对象也可以很方便地移动,甚至它还可以移动窗口的位置!  
    <img width="720px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/MoveTest.gif" alt="MoveTest.gif" />
    
    ```python
    """ Move Test """

    import tkintertools as tkt

    root = tkt.Tk('MoveTest', 500, 500)
    canvas = tkt.Canvas(root, 500, 500)
    canvas.place(x=0, y=0)

    rect = canvas.create_rectangle(50, 350, 150, 450)


    def move_window(switch: list[bool] = [True]) -> None:
        tkt.move(root, None, 1000 if switch[0] else -1000, 0, 800, 'flat')
        switch[0] = not switch[0]


    def move_button(switch: list[bool] = [True]) -> None:
        tkt.move(canvas, button, 200 if switch[0] else -200, 0, 500, 'rebound')
        switch[0] = not switch[0]


    def move_rect(switch: list[bool] = [True]) -> None:
        tkt.move(canvas, rect, 200 if switch[0] else -200, 0, 500, 'smooth')
        switch[0] = not switch[0]


    tkt.Button(canvas, 50, 50, 200, 40, 10, 'MoveWindow', command=move_window)
    tkt.Button(canvas, 50, 100, 200, 40, 10, 'MoveRect', command=move_rect)
    button = tkt.Button(canvas, 50, 150, 200, 40, 10,
                        'MoveButton', command=move_button)


    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

2. `text` : 文本函数

    可以快速并方便地得到一个参数长度的字符串,且字符串的内容可以指定位置  
    如:得到一个20长度的字符串“tkintertools”  
    <pre>
    `left`   : "tkintertools        "  
    `center` : "    tkintertools    "  
    `right`  : "        tkintertools"</pre>

3. `color` : 颜色函数

    颜色函数可以轻松求出一个颜色到另外一个颜色的过渡颜色,因此可以轻松得到渐变色的效果,同时,改变传入的参数还可以得到传入颜色的对比色  
    第二张图是 test.py 在图像测试中绘制的图案  
    <img width="360px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ColorTest.png" alt="ColorTest.png" />
    <img width="360px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/Test_Draw.png" alt="Test_Draw.png" />

    ```python
    """ Color Test """

    import tkintertools as tkt

    root = tkt.Tk('ColorTest', 500, 500)
    canvas = tkt.Canvas(root, 500, 500)
    canvas.place(x=0, y=0)


    def colorful(x: int, y: int, width: int, height: int) -> None:
        """ Gradient colors """
        for i in range(width):
            color = tkt.color(('#FF0000', '#00FF00'), i/width)
            color_2 = tkt.color(('#FFFFFF', '#000000'), i/width)
            canvas.create_line(x+i, y, x+i, y+height, fill=color)
            canvas.create_oval(250-i/3, 300-i/3, 250+i/3, 300 +
                            i/3, outline=color_2, width=2)


    colorful(50, 50, 400, 100)

    tkt.SetProcessDpiAwareness()
    root.mainloop()
    ```

4. `SetProcessDpiAwareness` : DPI 级别设置函数

    这个函数实际上只是对函数 `ctypes.OleDLL('shcore').SetProcessDpiAwareness` 的一个简单包装,其值可为 0、1 和 2,分别代表程序 DPI 的不同级别,那么缩放效果也就不同,`tkintertools` 选择的值是 1,但程序默认值实际为 0  
    下面是执行了这个函数的效果  
    <img width="720px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/SetProcessDpiAwareness_0.png" alt="SetProcessDpiAwareness_0.png" />  
    下面是未执行这个函数的效果  
    <img width="720px" src="https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/SetProcessDpiAwareness_1.png" alt="SetProcessDpiAwareness_1.png" />  
    从上面的两张图中可以很明显的看出第一张很模糊,第二张很清晰,这就是 DPI 级别不同的原因,不过这一点在平面缩放比不是 100% 的时候才会出现  
    大家对上面的图肯定很熟悉,这不就是 IDLE 吗!?对,这个的问题的解决办法也是来自于 IDLE 的源代码 [pyshell.py line 18~20]  
    注意:该函数在程序的不同位置执行的效果不一样!一般用在`mainloop`之前。

🚀More/更多
-----------

> GitCode:  
> https://gitcode.net/weixin_62651706/tkintertools

> GitHub(Mirror/镜像):  
> https://github.com/XiaoKang2022-CSDN/tkintertools

> Column/专栏:  
> https://blog.csdn.net/weixin_62651706/category_11600888.html

> Tutorials/教程:  
> https://xiaokang2022.blog.csdn.net/article/details/127374661

还有更多内容请在源码中探索!

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitcode.net/weixin_62651706/tkintertools",
    "name": "tkintertools-test",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Xiaokang2022",
    "author_email": "2951256653@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/c9/80/6476c50c7cfc82bff7cf63760757f14f0619d247cacba194b869bec031f3/tkintertools_test-3.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n    <h1>\ud83d\ude80<b>tkintertools</b>\ud83d\ude80</h1>\r\n    <img height=\"120px\" alt=\"logo.png\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/tkintertools.png\"/>\r\n    <p>The <code>tkintertools</code> module is an auxiliary module of the <code>tkinter</code> module</p>\r\n    <p><code>tkintertools</code> \u6a21\u5757\u662f <code>tkinter</code> \u6a21\u5757\u7684\u8f85\u52a9\u6a21\u5757</p>\r\n    <img src=\"https://img.shields.io/badge/Version-2.6.0-blue\" alt=\"latest version\" />\r\n    <a href=\"./LICENSE\">\r\n        <img src=\"https://img.shields.io/badge/License-Mulan PSL v2-green\" alt=\"License\" />\r\n    </a>\r\n    <a href=\"./CHANGELOG.md\">\r\n        <img src=\"https://img.shields.io/badge/ChangeLog-2023/03/28-orange\" alt=\"CHANGELOG\" />\r\n    </a>\r\n    <a href=\"./TODO.md\">\r\n    <img src=\"https://img.shields.io/badge/ToDo-5-yellow\" alt=\"TODO\" />\r\n    </a>\r\n    <br>\r\n    <img src=\"https://img.shields.io/badge/Mail-2951256653@qq.com-purple\" alt=\"Contact\" />\r\n    <a href=\"https://xiaokang2022.blog.csdn.net\">\r\n        <img src=\"https://img.shields.io/badge/Blog-https://xiaokang2022.blog.csdn.net-red\" alt=\"Blog\" />\r\n    </a>\r\n</div>\r\n\r\n\ud83d\ude80Installation/\u6a21\u5757\u5b89\u88c5\r\n-----------------------\r\n\r\n### \ud83d\udc49Stable version/\u7a33\u5b9a\u7248\u672c\r\n\r\n* Version/\u7248\u672c : 2.6.0\r\n* Release Date/\u53d1\u5e03\u65e5\u671f : 2023/03/28\r\n\r\n```\r\npip install tkintertools==2.6.0\r\n```\r\n\r\n### \ud83d\udc49Development version/\u5f00\u53d1\u7248\u672c\r\n\r\n* Version/\u7248\u672c : 2.6.0\r\n* Release Date/\u53d1\u5e03\u65e5\u671f : 2023/03/20\r\n\r\n```\r\npip install tkintertools-dev==2.6.0\r\n```\r\n\r\n\ud83d\ude80Description/\u6a21\u5757\u8bf4\u660e\r\n----------------------\r\n\r\n`tkintertools` \u662f\u4e00\u4e2a\u5b8c\u5168\u6ca1\u6709\u4f7f\u7528\u4efb\u4f55\u7b2c\u4e09\u65b9\u6a21\u5757\u548c\u5e93\u7684Python\u754c\u9762\u5f00\u53d1\u6a21\u5757\uff0c\u540c\u65f6\uff0c\u5b83\u4e5f\u6ca1\u6709\u4efb\u4f55\u4f9d\u8d56\u5305\uff0c\u5b83\u7684\u529f\u80fd\u5b8c\u5168\u7531\u5185\u7f6e\u6a21\u5757\u548c\u51fd\u6570\u5b9e\u73b0\u3002\r\n\r\n`tkintertools` \u662f\u4e00\u6b3e\u57fa\u4e8e `tkinter` \u6a21\u5757\u7684\u4e8c\u6b21\u5f00\u53d1\u7684\u754c\u9762\u7f16\u7a0b\u6a21\u5757\uff0c\u5b83\u548c `tkinter` \u6700\u5927\u7684\u4e0d\u540c\u5728\u4e8e\uff0c\u5b83\u7684\u63a7\u4ef6\u5e76\u975e\u771f\u5b9e\u7684\u63a7\u4ef6\uff0c\u800c\u662f\u5728 `tkinter` \u6a21\u5757\u4e2d `Canvas` \u5bf9\u8c61\u4e2d\u7ed8\u5236\u800c\u6210\u7684\uff0c\u8fd9\u5c31\u8d4b\u4e88\u4e86 `tkintertools` \u63a7\u4ef6\u4e00\u4e9b\u7279\u6027\uff0c\u5217\u4e3e\u5982\u4e0b\uff1a\r\n\r\n1. \u63a7\u4ef6\u80cc\u666f\u53ef\u4ee5\u662f\u900f\u660e\u7684\ud83d\udc4d\r\n2. \u63a7\u4ef6\u7684\u6837\u5f0f\u53ef\u4ee5\u662f\u81ea\u5b9a\u4e49\u7684\ud83d\udc4d\r\n3. \u63a7\u4ef6\u7684\u521b\u5efa\u901f\u5ea6\u662f\u8fdc\u5927\u4e8e `tkinter` \u7684\u63a7\u4ef6\u7684\ud83d\udc4d\r\n\r\n\u5f00\u53d1 `tkintertools` \u6a21\u5757\u9009\u7528\u7684 Python \u7248\u672c\u4e3a 3.10\uff0c\u5728\u8fd9\u4e2a\u53ca\u4ee5\u4e0a\u7248\u672c\u7684 Python \u62e5\u6709\u5f88\u597d\u7684\u7c7b\u578b\u63d0\u793a\u8bed\u6cd5\uff0c\u80fd\u4e3a\u7528\u6237\u63d0\u4f9b\u6700\u597d\u7684\u8bed\u6cd5\u63d0\u793a\u3002\u8fd9\u91cc\u6ca1\u6709\u9009\u62e9\u7528 .pyi \u5b58\u6839\u6587\u4ef6\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u7c7b\u578b\u63d0\u793a\u7684\u529f\u80fd\uff0c\u4e3b\u8981\u539f\u56e0\u662f .pyi \u6587\u4ef6\u4e0d\u65b9\u4fbf\u548c\u6a21\u5757\u771f\u6b63\u7684\u6587\u4ef6\u8fdb\u884c\u540c\u6b65\u4fee\u6539\uff0c\u800c\u4e14\u65e2\u7136\u8fd9\u4e2a\u7c7b\u578b\u63d0\u793a\u7684\u529f\u80fd\u5728 Python3.6\uff08Python3.10 \u7684\u7c7b\u578b\u63d0\u793a\u8bed\u6cd5\u5f97\u5230\u8fdb\u4e00\u6b65\u5f3a\u5316\uff09 \u4ee5\u4e0a\u5728\u6e90\u4ee3\u7801\u4e2d\u5b9e\u73b0\uff0c\u90a3\u4f55\u5fc5\u518d\u7528\u5b58\u6839\u6587\u4ef6\u5462\uff1f\r\n\r\n\u4f7f\u7528 Python3.10 \u5f3a\u5316\u4e86\u7684\u7c7b\u578b\u63d0\u793a\u8bed\u6cd5\u4e5f\u610f\u5473\u7740\u7528\u6237\u4f7f\u7528\u7684 Python \u7248\u672c\u4e5f\u5fc5\u987b\u81f3\u5c11\u4e3a 3.10\uff0c\u4e3a\u4e86\u5f25\u8865\u517c\u5bb9\u6027\uff0c\u540e\u7eed\u4f1a\u63a8\u51fa\u517c\u5bb9\u7248\u7684 tkintertools\u3002\u76ee\u524d\u9700\u8981\u517c\u5bb9\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u5728\u6e90\u4ee3\u7801\u4e2d\u81ea\u884c\u4fee\u6539\uff0c\u9700\u8981\u4fee\u6539\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a\r\n\r\n3.9 \u53ca\u66f4\u4f4e\u7248\u672c : \u7c7b\u578b\u63d0\u793a\u8bed\u6cd5\u4e2d\u7684 \u201c|\u201d\uff0cisinstance \u51fd\u6570\u4e2d\u7684 \u201c|\u201d  \r\n3.7 \u53ca\u66f4\u4f4e\u7248\u672c : \u8d4b\u503c\u8fd0\u7b97\u7b26\u7684\u6d77\u8c61\u8fd0\u7b97\u7b26 \u201c:=\u201d  \r\n3.6 \u53ca\u66f4\u4f4e\u7248\u672c : `fractions` \u6a21\u5757 `Fraction` \u7c7b\u7684 `limit_denominator` \u65b9\u6cd5\uff08\u5efa\u8bae\u5347\u7ea7Python\u7248\u672c\uff09  \r\n3.5 \u53ca\u66f4\u4f4e\u7248\u672c : \u5168\u90e8\u7684\u7c7b\u578b\u63d0\u793a\u8bed\u6cd5\uff08\u5efa\u8bae\u5347\u7ea7Python\u7248\u672c\uff09\r\n\r\n\ud83d\ude80Provides/\u6a21\u5757\u529f\u80fd\r\n-------------------\r\n\r\nHere, only the more distinctive features will be listed  \r\n\u8fd9\u91cc\u53ea\u4f1a\u5217\u4e3e\u51fa\u6bd4\u8f83\u5177\u6709\u7279\u8272\u7684\u529f\u80fd\r\n\r\n### \u2b50Customizable widgets/\u53ef\u81ea\u5b9a\u4e49\u7684\u63a7\u4ef6\r\n\r\n### \u2b50Automatically control size/\u81ea\u52a8\u63a7\u5236\u5927\u5c0f\r\n\r\n### \u2b50Easily move widgets/\u8f7b\u677e\u79fb\u52a8\u63a7\u4ef6\r\n\r\n### \u2b50Gradient colors/\u6e10\u53d8\u8272\r\n\r\n### \u2b50Automatically adapt to DPI/\u81ea\u52a8\u9002\u5e94DPI\r\n\r\n### \u2b50Scalable Picture/\u53ef\u7f29\u653e\u56fe\u7247\r\n\r\n### \u2b50Detailed type tips/\u8be6\u7ec6\u7684\u7c7b\u578b\u63d0\u793a\r\n\r\n\ud83d\ude80Contents/\u6a21\u5757\u5185\u5bb9\r\n-------------------\r\n\r\nEach non internal class and function in the module will be described in detail here  \r\n\u8fd9\u91cc\u4f1a\u8be6\u7ec6\u8bf4\u660e\u6a21\u5757\u4e2d\u7684\u6bcf\u4e2a\u975e\u5185\u90e8\u7c7b\u548c\u51fd\u6570\r\n\r\n### \u2b50Container Widget/\u5bb9\u5668\u63a7\u4ef6\r\n\r\n1. `Tk` : \u7a97\u53e3\u7c7b\r\n\r\n    \u7ee7\u627f\u4e8e `tkinter.Tk`\uff0c\u5728\u7ee7\u627f\u4e86 `tkinter` \u6a21\u5757\u5185 `Tk` \u7684\u57fa\u7840\u4e0a\uff0c\u53c8\u52a0\u5165\u4e86\u5bf9 `tkintertools` \u6a21\u5757\u4e2d\u7684 `Canvas` \u5bf9\u8c61\u7684\u652f\u6301\uff0c\u5e76\u52a0\u5165\u4e86\u68c0\u6d4b\u7a97\u53e3\u5927\u5c0f\u662f\u5426\u7f29\u653e\u7684\u673a\u5236\uff0c\u4ee5\u4f7f\u5f97\u5176\u5b50 `Canvas` \u5747\u80fd\u6b63\u786e\u5730\u8fdb\u884c\u7f29\u653e\r\n\r\n2. `Toplevel` : \u9876\u7ea7\u7a97\u53e3\u7c7b\r\n\r\n    \u7ee7\u627f\u4e8e `tkinter.Toplevel` \u548c `Tk`\uff0c\u52a0\u5165\u4e86\u5bf9 `tkintertools` \u6a21\u5757\u4e2d\u7684 `Canvas` \u5bf9\u8c61\u7684\u652f\u6301\uff0c\u5176\u4f59\u5747\u4e0e `Tk` \u4e00\u6837\r\n\r\n3. `Canvas` : \u753b\u5e03\u7c7b\r\n\r\n    \u7ee7\u627f\u4e8e `tkinter.Canvas`\uff0c\u52a0\u5165\u4e86\u5bf9\u753b\u5e03\u865a\u62df\u63a7\u4ef6\u7684\u652f\u6301\uff0c\u540c\u65f6\u662f\u5404\u7c7b\u54cd\u5e94\u4e8b\u4ef6\u3001\u7f29\u653e\u63a7\u5236\u7684\u7ba1\u7406\u8005\uff0c\u4e5f\u5bf9 `tkinter.Canvas` \u7684\u5b9e\u4f8b\u65b9\u6cd5\u6709\u4e00\u5b9a\u7684\u517c\u5bb9\u6027\r\n\r\n### \u2b50Virtual Canvas Widget/\u865a\u62df\u753b\u5e03\u63a7\u4ef6\r\n\r\n1. `Label` : \u6807\u7b7e\u63a7\u4ef6\r\n\r\n    \u6807\u7b7e\u63a7\u4ef6\u7684\u529f\u80fd\u548c `tkinter.Label` \u7684\u529f\u80fd\u7c7b\u4f3c\uff0c\u4f46\u66f4\u52a0\u7684\u591a\u5143\u5316  \r\n    \u4e0b\u9762\u662f `Label` \u63a7\u4ef6\u7684\u5916\u89c2\uff1a  \r\n    <img width=\"720px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/LabelTest.png\" alt=\"LabelTest.png\" />\r\n\r\n    ```python\r\n    \"\"\" Label Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('LabelTest', 1000, 400)\r\n    canvas = tkt.Canvas(root, 1000, 400)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#0000FF'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n\r\n\r\n    colorful(510, 175, 480, 150)\r\n\r\n    tkt.Label(canvas, 50, 50, 400, 100, 0, 'NormalLabel\\nHere is the text')\r\n    tkt.Label(canvas, 50, 200, 400, 100, 20, 'RoundCornerLabel')\r\n    tkt.Label(canvas, 550, 50, 400, 100, 0, 'DisableLabel').set_live(False)\r\n    tkt.Label(canvas, 550, 200, 400, 100, 20,\r\n            'TransparentLabel', color_fill=tkt.COLOR_NONE)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n2. `Button` : \u6309\u94ae\u63a7\u4ef6\r\n\r\n    \u6309\u94ae\u63a7\u4ef6\u76f8\u8f83\u4e8e `tkinter.Button` \uff0c\u5176\u81ea\u7531\u5ea6\u66f4\u9ad8\uff0c`tkinter.Button` \u53ea\u6709\u5728\u6309\u4e0b\u7684\u65f6\u5019\u624d\u80fd\u89e6\u53d1\u7ed1\u5b9a\u7684\u5173\u8054\u4e8b\u4ef6\uff0c\u800c `Button` \u5374\u53ef\u4ee5\u5728\u9f20\u6807\u79fb\u81f3\u6309\u94ae\u4e0a\u65b9\u65f6\u3001\u9f20\u6807\u6309\u4e0b\u65f6\u3001\u9f20\u6807\u677e\u5f00\u65f6\u90fd\u53ef\u4ee5\u7ed1\u5b9a\u5173\u8054\u4e8b\u4ef6  \r\n    \u4e0b\u9762\u662f `Button` \u63a7\u4ef6\u7684\u5916\u89c2\uff1a  \r\n    <img width=\"360px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ButtonTest.png\" alt=\"ButtonTest.png\" />\r\n\r\n    ```python\r\n    \"\"\" Button Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('ButtonTest', 500, 500)\r\n    canvas = tkt.Canvas(root, 500, 500)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#0000FF'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n\r\n\r\n    colorful(50, 280, 400, 100)\r\n\r\n    tkt.Button(canvas, 150, 135, 200, 50, 0, 'NormalButton')\r\n    tkt.Button(canvas, 100, 195, 300, 50, 10, 'RoundCornerButton')\r\n    tkt.Button(canvas, 150, 255, 200, 50, 0, 'DisableButton').set_live(False)\r\n    tkt.Button(canvas, 100, 315, 300, 50, 10,\r\n            'TransparentButton', color_fill=tkt.COLOR_NONE)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n3. `CheckButton` : \u590d\u9009\u6846\u63a7\u4ef6\r\n\r\n4. `Entry` : \u8f93\u5165\u6846\u63a7\u4ef6\r\n\r\n    \u8f93\u5165\u6846\u63a7\u4ef6\u53ef\u4ee5\u8f7b\u677e\u5730\u8bbe\u7f6e\u8f93\u5165\u7684\u6587\u672c\u4f4d\u7f6e\uff08\u9760\u5de6\u3001\u5c45\u4e2d\u548c\u9760\u53f3\uff09\uff0c\u540c\u65f6\uff0c\u5b83\u53ef\u4ee5\u5728\u9f20\u6807\u79fb\u81f3\u8f93\u5165\u6846\u4e0a\u65b9\u3001\u9f20\u6807\u672a\u5728\u8f93\u5165\u6846\u4e0a\u65b9\u4e24\u79cd\u72b6\u6001\u663e\u793a\u4e0d\u540c\u7684\u9ed8\u8ba4\u6587\u672c  \r\n    \u4e0b\u9762\u662f `Entry` \u63a7\u4ef6\u7684\u5916\u89c2\uff1a  \r\n    <img width=\"360px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/EntryTest.png\" alt=\"EntryTest.png\" />\r\n    \r\n    ```python\r\n    \"\"\" Entry Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('EntryTest', 500, 400)\r\n    canvas = tkt.Canvas(root, 500, 400)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#0000FF'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n\r\n\r\n    colorful(50, 193, 400, 100)\r\n    tkt.Entry(canvas, 20, 20, 200, 30, 0, ('LeftEntry', 'Enter'))\r\n    tkt.Entry(canvas, 20, 55, 200, 30, 0,\r\n            ('CenterEntry', 'Enter'), justify='center')\r\n    tkt.Entry(canvas, 20, 90, 200, 30, 0, ('RightEntry', 'Enter'), justify='right')\r\n    tkt.Entry(canvas, 270, 20, 200, 30, 8, 'LeftEntry')\r\n    tkt.Entry(canvas, 270, 55, 200, 30, 8, 'CenterEntry', justify='center')\r\n    tkt.Entry(canvas, 270, 90, 200, 30, 8, 'RightEntry', justify='right')\r\n\r\n    tkt.Entry(canvas, 100, 150, 300, 35, 0,\r\n            ('PasswordEntry', 'Click To Enter'), justify='center', show='\u2022')\r\n    tkt.Entry(canvas, 100, 200, 300, 35, 0, 'DisableEntry',\r\n            justify='center').set_live(False)\r\n    tkt.Entry(canvas, 100, 250, 300, 35, 0, 'TransparentEntry',\r\n            justify='center', color_fill=tkt.COLOR_NONE)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n5. `Text` : \u6587\u672c\u6846\u63a7\u4ef6\r\n\r\n    \u6587\u672c\u6846\u7c7b\u4f3c\u4e8e\u8f93\u5165\u6846\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u8d58\u8ff0  \r\n    \u4e0b\u9762\u662f `Text` \u63a7\u4ef6\u7684\u5916\u89c2\uff1a  \r\n    <img width=\"720px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/TextTest.png\" alt=\"TextTest.png\" />\r\n\r\n    ```python\r\n    \"\"\" Text Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('TextTest', 1000, 400)\r\n    canvas = tkt.Canvas(root, 1000, 400)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#0000FF'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n\r\n\r\n    colorful(510, 175, 480, 150)\r\n\r\n    tkt.Text(canvas, 50, 50, 400, 100, 0, ('NormalText(Left)', 'Click To Enter'))\r\n    tkt.Text(canvas, 50, 200, 400, 100, 20,\r\n            'RoundCornerText(Center)', justify='center')\r\n    tkt.Text(canvas, 550, 50, 400, 100, 0, 'DisableText').set_live(False)\r\n    tkt.Text(canvas, 550, 200, 400, 100, 20,\r\n            'TransparentText(Right)', justify='right', color_fill=tkt.COLOR_NONE)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n6. `Progressbar` : \u8fdb\u5ea6\u6761\u63a7\u4ef6\r\n\r\n    \u8fdb\u5ea6\u6761\u63a7\u4ef6\u76f8\u6bd4 `tkinter.ttk.Progressbar`\uff0c\u5916\u89c2\u4e0a\u7684\u81ea\u7531\u5ea6\u8f83\u5927  \r\n    \u4e0b\u9762\u662f `Progressbar` \u63a7\u4ef6\u7684\u5916\u89c2\uff1a  \r\n    <img width=\"360px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ProgressbarTest.png\" alt=\"ProgressbarTest.png\" />\r\n\r\n    ```python\r\n    \"\"\" Progressbar Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('ProgressbarTest', 500, 500)\r\n    canvas = tkt.Canvas(root, 500, 500)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#0000FF'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n\r\n\r\n    colorful(30, 290, 440, 50)\r\n\r\n    tkt.Progressbar(canvas, 50, 50, 400, 30)\r\n    tkt.Progressbar(canvas, 50, 100, 400, 30).load(.6667)\r\n    tkt.Progressbar(canvas, 50, 150, 400, 30, 5).load(1)\r\n    (_ := tkt.Progressbar(canvas, 50, 200, 400, 30)).load(0.3333)\r\n    _.set_live(False)\r\n    tkt.Progressbar(canvas, 50, 250, 400, 30, color_bar=(\r\n        'lightyellow', 'skyblue')).load(.5)\r\n    tkt.Progressbar(canvas, 50, 300, 400, 30, color_bar=('', 'orange')).load(.1667)\r\n\r\n    progressbar = tkt.Progressbar(canvas, 50, 375, 400, 30)\r\n    progressbar_2 = tkt.Progressbar(canvas, 50, 425, 400, 30)\r\n\r\n\r\n    def load(total: int, count: int = 0) -> None:\r\n        \"\"\" load progressbar \"\"\"\r\n        progressbar.load(count/total)\r\n        progressbar_2.load(1-count/total)\r\n        if count < total:\r\n            root.after(3, load, total, count+1)\r\n\r\n\r\n    load(10000)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n### \u2b50Tool Class/\u5de5\u5177\u7c7b\r\n\r\n1. `PhotoImage` : \u56fe\u7247\u7c7b\r\n\r\n    `PhotoImage` \u7c7b\u7ee7\u627f\u4e8e `tkinter.PhotoImage`\uff0c\u5b83\u662f\u5728 `tkinter.PhotoImage` \u7684\u57fa\u7840\u4e0a\u505a\u529f\u80fd\u7684\u5f3a\u5316\uff0c\u5bf9 gif \u52a8\u56fe\u6709\u5f88\u597d\u7684\u652f\u6301\uff0c\u4ec5\u9700\u6781\u5c11\u91cf\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0\u52a8\u56fe\u7684\u663e\u793a\uff0c\u8fd8\u53ef\u4ee5\u8bbe\u7f6e\u52a8\u56fe\u663e\u793a\u7684\u901f\u5ea6\uff0c\u6b64\u5916\uff0c\u5bf9 png \u7c7b\u578b\u7684\u56fe\u7247\u7684\u652f\u6301\u4e5f\u6709\u5f3a\u5316\uff0c\u53ef\u4ee5\u5728\u4e0d\u4f9d\u8d56\u4efb\u4f55\u7b2c\u4e09\u65b9\u6a21\u5757\u6216\u8005\u5e93\u7684\u60c5\u51b5\u4e0b\uff0c\u5bf9\u56fe\u7247\u8fdb\u884c\u7f29\u653e\r\n\r\n2. `Singleton` : \u5355\u4f8b\u6a21\u5f0f\u7c7b\r\n\r\n    \u5355\u4f8b\u6a21\u5f0f\uff0c\u4e0d\u7528\u4ecb\u7ecd\u4e86\u5427\uff1f\u901a\u8fc7\u7ee7\u627f\u5b83\u6765\u4f7f\u7528\r\n\r\n### \u2b50Tool Function/\u5de5\u5177\u51fd\u6570\r\n\r\n1. `move` : \u79fb\u52a8\u51fd\u6570\r\n\r\n    \u79fb\u52a8\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u5730\u6309\u4e00\u5b9a\u7684\u89c4\u5f8b\u3001\u79fb\u52a8\u901f\u5ea6\u3001\u79fb\u52a8\u65f6\u95f4\u53bb\u79fb\u52a8 `tkintertools` \u6a21\u5757\u5185\u7684\u6240\u6709\u5bf9\u8c61\uff0c\u540c\u65f6\u517c\u5bb9\u4e86 `tkinter` \u5185\u7684\u5bf9\u8c61\uff0c\u5373 `tkinter` \u4e2d\u7684\u5bf9\u8c61\u4e5f\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u79fb\u52a8\uff0c\u751a\u81f3\u5b83\u8fd8\u53ef\u4ee5\u79fb\u52a8\u7a97\u53e3\u7684\u4f4d\u7f6e\uff01  \r\n    <img width=\"720px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/MoveTest.gif\" alt=\"MoveTest.gif\" />\r\n    \r\n    ```python\r\n    \"\"\" Move Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('MoveTest', 500, 500)\r\n    canvas = tkt.Canvas(root, 500, 500)\r\n    canvas.place(x=0, y=0)\r\n\r\n    rect = canvas.create_rectangle(50, 350, 150, 450)\r\n\r\n\r\n    def move_window(switch: list[bool] = [True]) -> None:\r\n        tkt.move(root, None, 1000 if switch[0] else -1000, 0, 800, 'flat')\r\n        switch[0] = not switch[0]\r\n\r\n\r\n    def move_button(switch: list[bool] = [True]) -> None:\r\n        tkt.move(canvas, button, 200 if switch[0] else -200, 0, 500, 'rebound')\r\n        switch[0] = not switch[0]\r\n\r\n\r\n    def move_rect(switch: list[bool] = [True]) -> None:\r\n        tkt.move(canvas, rect, 200 if switch[0] else -200, 0, 500, 'smooth')\r\n        switch[0] = not switch[0]\r\n\r\n\r\n    tkt.Button(canvas, 50, 50, 200, 40, 10, 'MoveWindow', command=move_window)\r\n    tkt.Button(canvas, 50, 100, 200, 40, 10, 'MoveRect', command=move_rect)\r\n    button = tkt.Button(canvas, 50, 150, 200, 40, 10,\r\n                        'MoveButton', command=move_button)\r\n\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n2. `text` : \u6587\u672c\u51fd\u6570\r\n\r\n    \u53ef\u4ee5\u5feb\u901f\u5e76\u65b9\u4fbf\u5730\u5f97\u5230\u4e00\u4e2a\u53c2\u6570\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\uff0c\u4e14\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u53ef\u4ee5\u6307\u5b9a\u4f4d\u7f6e  \r\n    \u5982\uff1a\u5f97\u5230\u4e00\u4e2a20\u957f\u5ea6\u7684\u5b57\u7b26\u4e32\u201ctkintertools\u201d  \r\n    <pre>\r\n    `left`   : \"tkintertools        \"  \r\n    `center` : \"    tkintertools    \"  \r\n    `right`  : \"        tkintertools\"</pre>\r\n\r\n3. `color` : \u989c\u8272\u51fd\u6570\r\n\r\n    \u989c\u8272\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u6c42\u51fa\u4e00\u4e2a\u989c\u8272\u5230\u53e6\u5916\u4e00\u4e2a\u989c\u8272\u7684\u8fc7\u6e21\u989c\u8272\uff0c\u56e0\u6b64\u53ef\u4ee5\u8f7b\u677e\u5f97\u5230\u6e10\u53d8\u8272\u7684\u6548\u679c\uff0c\u540c\u65f6\uff0c\u6539\u53d8\u4f20\u5165\u7684\u53c2\u6570\u8fd8\u53ef\u4ee5\u5f97\u5230\u4f20\u5165\u989c\u8272\u7684\u5bf9\u6bd4\u8272  \r\n    \u7b2c\u4e8c\u5f20\u56fe\u662f test.py \u5728\u56fe\u50cf\u6d4b\u8bd5\u4e2d\u7ed8\u5236\u7684\u56fe\u6848  \r\n    <img width=\"360px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/ColorTest.png\" alt=\"ColorTest.png\" />\r\n    <img width=\"360px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/Test_Draw.png\" alt=\"Test_Draw.png\" />\r\n\r\n    ```python\r\n    \"\"\" Color Test \"\"\"\r\n\r\n    import tkintertools as tkt\r\n\r\n    root = tkt.Tk('ColorTest', 500, 500)\r\n    canvas = tkt.Canvas(root, 500, 500)\r\n    canvas.place(x=0, y=0)\r\n\r\n\r\n    def colorful(x: int, y: int, width: int, height: int) -> None:\r\n        \"\"\" Gradient colors \"\"\"\r\n        for i in range(width):\r\n            color = tkt.color(('#FF0000', '#00FF00'), i/width)\r\n            color_2 = tkt.color(('#FFFFFF', '#000000'), i/width)\r\n            canvas.create_line(x+i, y, x+i, y+height, fill=color)\r\n            canvas.create_oval(250-i/3, 300-i/3, 250+i/3, 300 +\r\n                            i/3, outline=color_2, width=2)\r\n\r\n\r\n    colorful(50, 50, 400, 100)\r\n\r\n    tkt.SetProcessDpiAwareness()\r\n    root.mainloop()\r\n    ```\r\n\r\n4. `SetProcessDpiAwareness` : DPI \u7ea7\u522b\u8bbe\u7f6e\u51fd\u6570\r\n\r\n    \u8fd9\u4e2a\u51fd\u6570\u5b9e\u9645\u4e0a\u53ea\u662f\u5bf9\u51fd\u6570 `ctypes.OleDLL('shcore').SetProcessDpiAwareness` \u7684\u4e00\u4e2a\u7b80\u5355\u5305\u88c5\uff0c\u5176\u503c\u53ef\u4e3a 0\u30011 \u548c 2\uff0c\u5206\u522b\u4ee3\u8868\u7a0b\u5e8f DPI \u7684\u4e0d\u540c\u7ea7\u522b\uff0c\u90a3\u4e48\u7f29\u653e\u6548\u679c\u4e5f\u5c31\u4e0d\u540c\uff0c`tkintertools` \u9009\u62e9\u7684\u503c\u662f 1\uff0c\u4f46\u7a0b\u5e8f\u9ed8\u8ba4\u503c\u5b9e\u9645\u4e3a 0  \r\n    \u4e0b\u9762\u662f\u6267\u884c\u4e86\u8fd9\u4e2a\u51fd\u6570\u7684\u6548\u679c  \r\n    <img width=\"720px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/SetProcessDpiAwareness_0.png\" alt=\"SetProcessDpiAwareness_0.png\" />  \r\n    \u4e0b\u9762\u662f\u672a\u6267\u884c\u8fd9\u4e2a\u51fd\u6570\u7684\u6548\u679c  \r\n    <img width=\"720px\" src=\"https://gitcode.net/weixin_62651706/tkintertools/-/raw/master/docs/images/SetProcessDpiAwareness_1.png\" alt=\"SetProcessDpiAwareness_1.png\" />  \r\n    \u4ece\u4e0a\u9762\u7684\u4e24\u5f20\u56fe\u4e2d\u53ef\u4ee5\u5f88\u660e\u663e\u7684\u770b\u51fa\u7b2c\u4e00\u5f20\u5f88\u6a21\u7cca\uff0c\u7b2c\u4e8c\u5f20\u5f88\u6e05\u6670\uff0c\u8fd9\u5c31\u662f DPI \u7ea7\u522b\u4e0d\u540c\u7684\u539f\u56e0\uff0c\u4e0d\u8fc7\u8fd9\u4e00\u70b9\u5728\u5e73\u9762\u7f29\u653e\u6bd4\u4e0d\u662f 100% \u7684\u65f6\u5019\u624d\u4f1a\u51fa\u73b0  \r\n    \u5927\u5bb6\u5bf9\u4e0a\u9762\u7684\u56fe\u80af\u5b9a\u5f88\u719f\u6089\uff0c\u8fd9\u4e0d\u5c31\u662f IDLE \u5417\uff01\uff1f\u5bf9\uff0c\u8fd9\u4e2a\u7684\u95ee\u9898\u7684\u89e3\u51b3\u529e\u6cd5\u4e5f\u662f\u6765\u81ea\u4e8e IDLE \u7684\u6e90\u4ee3\u7801 [pyshell.py line 18~20]  \r\n    \u6ce8\u610f\uff1a\u8be5\u51fd\u6570\u5728\u7a0b\u5e8f\u7684\u4e0d\u540c\u4f4d\u7f6e\u6267\u884c\u7684\u6548\u679c\u4e0d\u4e00\u6837\uff01\u4e00\u822c\u7528\u5728`mainloop`\u4e4b\u524d\u3002\r\n\r\n\ud83d\ude80More/\u66f4\u591a\r\n-----------\r\n\r\n> GitCode:  \r\n> https://gitcode.net/weixin_62651706/tkintertools\r\n\r\n> GitHub(Mirror/\u955c\u50cf):  \r\n> https://github.com/XiaoKang2022-CSDN/tkintertools\r\n\r\n> Column/\u4e13\u680f:  \r\n> https://blog.csdn.net/weixin_62651706/category_11600888.html\r\n\r\n> Tutorials/\u6559\u7a0b:  \r\n> https://xiaokang2022.blog.csdn.net/article/details/127374661\r\n\r\n\u8fd8\u6709\u66f4\u591a\u5185\u5bb9\u8bf7\u5728\u6e90\u7801\u4e2d\u63a2\u7d22\uff01\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "An auxiliary module of the tkinder module",
    "version": "3",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65d49191ee03d16721fda4b17e0e5112db2fa6f1b17453f8be4efd8be3ebd32a",
                "md5": "e2d6e32edfc80c01d32733441fe68a9b",
                "sha256": "f1b2a13d5133d91458bc19af9b23d5ccaa224dcb4ce51aa903d44376d6512c01"
            },
            "downloads": -1,
            "filename": "tkintertools_test-3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e2d6e32edfc80c01d32733441fe68a9b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 25060,
            "upload_time": "2023-03-28T05:01:01",
            "upload_time_iso_8601": "2023-03-28T05:01:01.712599Z",
            "url": "https://files.pythonhosted.org/packages/65/d4/9191ee03d16721fda4b17e0e5112db2fa6f1b17453f8be4efd8be3ebd32a/tkintertools_test-3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9806476c50c7cfc82bff7cf63760757f14f0619d247cacba194b869bec031f3",
                "md5": "e158e43da356d23687e8ac36df984a51",
                "sha256": "cf86f7b8895c646dd3934857a114357005c017664c3dc0dbedc74a392fc63cd8"
            },
            "downloads": -1,
            "filename": "tkintertools_test-3.tar.gz",
            "has_sig": false,
            "md5_digest": "e158e43da356d23687e8ac36df984a51",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29669,
            "upload_time": "2023-03-28T05:01:03",
            "upload_time_iso_8601": "2023-03-28T05:01:03.560718Z",
            "url": "https://files.pythonhosted.org/packages/c9/80/6476c50c7cfc82bff7cf63760757f14f0619d247cacba194b869bec031f3/tkintertools_test-3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-28 05:01:03",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "tkintertools-test"
}
        
Elapsed time: 3.45869s