TkGifWidget


NameTkGifWidget JSON
Version 0.0.9 PyPI version JSON
download
home_pageNone
SummaryA widget that displays GIFs in Tkinter
upload_time2025-08-15 15:21:44
maintainerNone
docs_urlNone
authorJellyfisHawthorn
requires_python>=3.8
licenseNone
keywords tkinter gif widget animated
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TkGifWidget

A widget that displays GIFs in Tkinter.  
一个能在Tkinter中显示GIF动图的控件。

![GitHub License](https://img.shields.io/github/license/JellyfisHawthorn/TkGifWidgit)
![PyPI - Version](https://img.shields.io/pypi/v/TkGifWidget)
![dependce](https://img.shields.io/badge/dependence-Pillow-brightgreen?link=https%3A%2F%2Fgithub.com%2Fpython-pillow%2FPillow
)


## Language

- [English](#english)
- [简体中文](#简体中文)

---

## English

### Overview

This module provides a widget class called AnimatedGif, which can display GIF animations (including some other formats).

The AnimatedGif widget supports setting the number of loops, the image to be displayed when the animation is not playing, and the callback function to be executed when the animation is completed, etc.

In addition, the AnimatedGif widget supports three playback modes, which are:

- click: background image is displayed before the animation starts, and the animation is played when clicked, and the background image is displayed again when clicked again.

![click](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/click.gif)

- display: the animation is played when the AnimatedGif widget is mapped, and the animation is stopped when the widget is unmapped.

![display](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/display.gif)

- hover: the animation is played when the mouse moves over the AnimatedGif widget, and the animation is stopped when the mouse moves out of the widget.

![hover](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/hover.gif)

### Installation and Import

Install using pip:
```
pip install TkGifWidget
```

Import:
```python3
from TkGifWidget import *
# or import TkGifWidget
```

### Usage
[example.py](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/case/example.py):
```python3
import tkinter as tk
from TkGifWidget import AnimatedGif
root = tk.Tk()
# Create an AnimatedGif widget, play when displayed
gif = AnimatedGif('../gif/example.gif', play_mode='display')
gif.pack()
root.mainloop()
```

For more information, please refer to the Wiki:

https://github.com/JellyfisHawthorn/TkGifWidget/wiki/English

### Shortcoming

Because of the way Tk loads images, GIF animations with **irregular** opacity can be slow to load.

---

## 简体中文

### 概述

此模块提供了一个名为AnimatedGif的控件类,用于显示GIF动图(也支持一些其他动图格式)。

动图控件支持设置动图的循环次数、未播放时显示的图片、播放完成后执行的回调函数等等。

此外,动图控件支持三种播放模式,分别是:

- click(点击):点击前显示背景图,点击后播放动图,再次点击重新显示背景图。

![点击](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/click.gif)

- display(显示):动图控件被映射时开始播放动图,取消映射时结束播放动图。

![显示](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/display.gif)

- hover:当鼠标移动到动图控件上时播放动图,移出动图控件结束播放动图。

![悬停](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/hover.gif)

### 安装和导入

使用pip安装:
```
pip install TkGifWidget
```

导入方式:
```python3
from TkGifWidget import *
# 或者使用import TkGifWidget
```

### 使用

[example.py](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/case/example.py):
```python3
import tkinter as tk
from TkGifWidget import AnimatedGif
root = tk.Tk()
# 创建动图控件,显示时播放
gif = AnimatedGif('../gif/example.gif', play_mode='display')
gif.pack()
root.mainloop()
```

具体请查看Wiki:https://github.com/JellyfisHawthorn/TkGifWidget/wiki/%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87

Bilibili上的介绍文章(版本较旧):https://www.bilibili.com/read/cv31300353/  

### 缺陷

因为Tk的图像加载方式,极少部分透明度**不规则**的GIF动图加载速度会极慢。

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "TkGifWidget",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "tkinter, gif, widget, Animated",
    "author": "JellyfisHawthorn",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/53/9b/e3b3ca6de635009ddb5b47d0a17510b8fb9e92fc53de82b1559fc5f77e24/tkgifwidget-0.0.9.tar.gz",
    "platform": null,
    "description": "# TkGifWidget\n\nA widget that displays GIFs in Tkinter.  \n\u4e00\u4e2a\u80fd\u5728Tkinter\u4e2d\u663e\u793aGIF\u52a8\u56fe\u7684\u63a7\u4ef6\u3002\n\n![GitHub License](https://img.shields.io/github/license/JellyfisHawthorn/TkGifWidgit)\n![PyPI - Version](https://img.shields.io/pypi/v/TkGifWidget)\n![dependce](https://img.shields.io/badge/dependence-Pillow-brightgreen?link=https%3A%2F%2Fgithub.com%2Fpython-pillow%2FPillow\n)\n\n\n## Language\n\n- [English](#english)\n- [\u7b80\u4f53\u4e2d\u6587](#\u7b80\u4f53\u4e2d\u6587)\n\n---\n\n## English\n\n### Overview\n\nThis module provides a widget class called AnimatedGif, which can display GIF animations (including some other formats).\n\nThe AnimatedGif widget supports setting the number of loops, the image to be displayed when the animation is not playing, and the callback function to be executed when the animation is completed, etc.\n\nIn addition, the AnimatedGif widget supports three playback modes, which are:\n\n- click: background image is displayed before the animation starts, and the animation is played when clicked, and the background image is displayed again when clicked again.\n\n![click](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/click.gif)\n\n- display: the animation is played when the AnimatedGif widget is mapped, and the animation is stopped when the widget is unmapped.\n\n![display](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/display.gif)\n\n- hover: the animation is played when the mouse moves over the AnimatedGif widget, and the animation is stopped when the mouse moves out of the widget.\n\n![hover](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/en_us/hover.gif)\n\n### Installation and Import\n\nInstall using pip:\n```\npip install TkGifWidget\n```\n\nImport:\n```python3\nfrom TkGifWidget import *\n# or import TkGifWidget\n```\n\n### Usage\n[example.py](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/case/example.py):\n```python3\nimport tkinter as tk\nfrom TkGifWidget import AnimatedGif\nroot = tk.Tk()\n# Create an AnimatedGif widget, play when displayed\ngif = AnimatedGif('../gif/example.gif', play_mode='display')\ngif.pack()\nroot.mainloop()\n```\n\nFor more information, please refer to the Wiki:\n\nhttps://github.com/JellyfisHawthorn/TkGifWidget/wiki/English\n\n### Shortcoming\n\nBecause of the way Tk loads images, GIF animations with **irregular** opacity can be slow to load.\n\n---\n\n## \u7b80\u4f53\u4e2d\u6587\n\n### \u6982\u8ff0\n\n\u6b64\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e2a\u540d\u4e3aAnimatedGif\u7684\u63a7\u4ef6\u7c7b\uff0c\u7528\u4e8e\u663e\u793aGIF\u52a8\u56fe\uff08\u4e5f\u652f\u6301\u4e00\u4e9b\u5176\u4ed6\u52a8\u56fe\u683c\u5f0f\uff09\u3002\n\n\u52a8\u56fe\u63a7\u4ef6\u652f\u6301\u8bbe\u7f6e\u52a8\u56fe\u7684\u5faa\u73af\u6b21\u6570\u3001\u672a\u64ad\u653e\u65f6\u663e\u793a\u7684\u56fe\u7247\u3001\u64ad\u653e\u5b8c\u6210\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\u7b49\u7b49\u3002\n\n\u6b64\u5916\uff0c\u52a8\u56fe\u63a7\u4ef6\u652f\u6301\u4e09\u79cd\u64ad\u653e\u6a21\u5f0f\uff0c\u5206\u522b\u662f\uff1a\n\n- click\uff08\u70b9\u51fb\uff09\uff1a\u70b9\u51fb\u524d\u663e\u793a\u80cc\u666f\u56fe\uff0c\u70b9\u51fb\u540e\u64ad\u653e\u52a8\u56fe\uff0c\u518d\u6b21\u70b9\u51fb\u91cd\u65b0\u663e\u793a\u80cc\u666f\u56fe\u3002\n\n![\u70b9\u51fb](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/click.gif)\n\n- display\uff08\u663e\u793a\uff09\uff1a\u52a8\u56fe\u63a7\u4ef6\u88ab\u6620\u5c04\u65f6\u5f00\u59cb\u64ad\u653e\u52a8\u56fe\uff0c\u53d6\u6d88\u6620\u5c04\u65f6\u7ed3\u675f\u64ad\u653e\u52a8\u56fe\u3002\n\n![\u663e\u793a](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/display.gif)\n\n- hover\uff1a\u5f53\u9f20\u6807\u79fb\u52a8\u5230\u52a8\u56fe\u63a7\u4ef6\u4e0a\u65f6\u64ad\u653e\u52a8\u56fe\uff0c\u79fb\u51fa\u52a8\u56fe\u63a7\u4ef6\u7ed3\u675f\u64ad\u653e\u52a8\u56fe\u3002\n\n![\u60ac\u505c](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/gif/zh_cn/hover.gif)\n\n### \u5b89\u88c5\u548c\u5bfc\u5165\n\n\u4f7f\u7528pip\u5b89\u88c5\uff1a\n```\npip install TkGifWidget\n```\n\n\u5bfc\u5165\u65b9\u5f0f\uff1a\n```python3\nfrom TkGifWidget import *\n# \u6216\u8005\u4f7f\u7528import TkGifWidget\n```\n\n### \u4f7f\u7528\n\n[example.py](https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/docs/case/example.py)\uff1a\n```python3\nimport tkinter as tk\nfrom TkGifWidget import AnimatedGif\nroot = tk.Tk()\n# \u521b\u5efa\u52a8\u56fe\u63a7\u4ef6\uff0c\u663e\u793a\u65f6\u64ad\u653e\ngif = AnimatedGif('../gif/example.gif', play_mode='display')\ngif.pack()\nroot.mainloop()\n```\n\n\u5177\u4f53\u8bf7\u67e5\u770bWiki\uff1ahttps://github.com/JellyfisHawthorn/TkGifWidget/wiki/%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87\n\nBilibili\u4e0a\u7684\u4ecb\u7ecd\u6587\u7ae0\uff08\u7248\u672c\u8f83\u65e7\uff09\uff1ahttps://www.bilibili.com/read/cv31300353/  \n\n### \u7f3a\u9677\n\n\u56e0\u4e3aTk\u7684\u56fe\u50cf\u52a0\u8f7d\u65b9\u5f0f\uff0c\u6781\u5c11\u90e8\u5206\u900f\u660e\u5ea6**\u4e0d\u89c4\u5219**\u7684GIF\u52a8\u56fe\u52a0\u8f7d\u901f\u5ea6\u4f1a\u6781\u6162\u3002\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A widget that displays GIFs in Tkinter",
    "version": "0.0.9",
    "project_urls": {
        "Changelog": "https://github.com/JellyfisHawthorn/TkGifWidget/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/JellyfisHawthorn/TkGifWidgit",
        "Issues": "https://github.com/JellyfisHawthorn/TkGifWidgit/issues"
    },
    "split_keywords": [
        "tkinter",
        " gif",
        " widget",
        " animated"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "095eb812b5c46176ed747230bec40fd81a84ff1ca266783b56fa379972f1cfe3",
                "md5": "91e902c401408ce290515dc830a584f9",
                "sha256": "b75ce26776267451b25fb0a0f3c0f63ce574ca3b95fae98e89a7e3935d53b2d3"
            },
            "downloads": -1,
            "filename": "tkgifwidget-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91e902c401408ce290515dc830a584f9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10429,
            "upload_time": "2025-08-15T15:21:43",
            "upload_time_iso_8601": "2025-08-15T15:21:43.204958Z",
            "url": "https://files.pythonhosted.org/packages/09/5e/b812b5c46176ed747230bec40fd81a84ff1ca266783b56fa379972f1cfe3/tkgifwidget-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "539be3b3ca6de635009ddb5b47d0a17510b8fb9e92fc53de82b1559fc5f77e24",
                "md5": "f65d6226e015cc3fa886b6d1b9234043",
                "sha256": "713ba7a7a93e4d032b8457569c46d86d7d897cc1482733a40095a77288e48758"
            },
            "downloads": -1,
            "filename": "tkgifwidget-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "f65d6226e015cc3fa886b6d1b9234043",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11146,
            "upload_time": "2025-08-15T15:21:44",
            "upload_time_iso_8601": "2025-08-15T15:21:44.551735Z",
            "url": "https://files.pythonhosted.org/packages/53/9b/e3b3ca6de635009ddb5b47d0a17510b8fb9e92fc53de82b1559fc5f77e24/tkgifwidget-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 15:21:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JellyfisHawthorn",
    "github_project": "TkGifWidget",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tkgifwidget"
}
        
Elapsed time: 0.56263s