A widget that displays GIFs in Tkinter
Project description
TkGifWidget
A widget that displays GIFs in Tkinter.
一个能在Tkinter中显示GIF动图的控件。
Language
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.
- display: the animation is played when the AnimatedGif widget is mapped, and the animation is stopped when the widget is unmapped.
- 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.
Installation and Import
Install using pip:
pip install TkGifWidget
Import:
from TkGifWidget import *
# or import TkGifWidget
Usage
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(点击):点击前显示背景图,点击后播放动图,再次点击重新显示背景图。
- display(显示):动图控件被映射时开始播放动图,取消映射时结束播放动图。
- hover:当鼠标移动到动图控件上时播放动图,移出动图控件结束播放动图。
安装和导入
使用pip安装:
pip install TkGifWidget
导入方式:
from TkGifWidget import *
# 或者使用import TkGifWidget
使用
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动图加载速度会极慢。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tkgifwidget-0.0.9a2.tar.gz.
File metadata
- Download URL: tkgifwidget-0.0.9a2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73959c355d1fab04896a7c2ab3ac5c0d52f0942269ee36d65fc0fd31789e8991
|
|
| MD5 |
aaebc9c8418b4eab80ce857e64704367
|
|
| BLAKE2b-256 |
e1ae4a01f69672922ed1a4760685780d8b6bd3aaefe7142aee648964b0bdcd5a
|
Provenance
The following attestation bundles were made for tkgifwidget-0.0.9a2.tar.gz:
Publisher:
publish.yml on JellyfisHawthorn/TkGifWidget
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tkgifwidget-0.0.9a2.tar.gz -
Subject digest:
73959c355d1fab04896a7c2ab3ac5c0d52f0942269ee36d65fc0fd31789e8991 - Sigstore transparency entry: 398115511
- Sigstore integration time:
-
Permalink:
JellyfisHawthorn/TkGifWidget@5e4703d6f750cc7a745a376b2c35ede7f961c942 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JellyfisHawthorn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e4703d6f750cc7a745a376b2c35ede7f961c942 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tkgifwidget-0.0.9a2-py3-none-any.whl.
File metadata
- Download URL: tkgifwidget-0.0.9a2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39ee43aeac6984849df0f473201313c41f4ed4ed96390b798d185910b77c1d85
|
|
| MD5 |
82cf21125b7ec222fe547611cb4ef82a
|
|
| BLAKE2b-256 |
94efb6d8fe2936e4574552b88effc8c331840b27dd7a015c7e6cf66a7ca8661a
|
Provenance
The following attestation bundles were made for tkgifwidget-0.0.9a2-py3-none-any.whl:
Publisher:
publish.yml on JellyfisHawthorn/TkGifWidget
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tkgifwidget-0.0.9a2-py3-none-any.whl -
Subject digest:
39ee43aeac6984849df0f473201313c41f4ed4ed96390b798d185910b77c1d85 - Sigstore transparency entry: 398115513
- Sigstore integration time:
-
Permalink:
JellyfisHawthorn/TkGifWidget@5e4703d6f750cc7a745a376b2c35ede7f961c942 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JellyfisHawthorn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5e4703d6f750cc7a745a376b2c35ede7f961c942 -
Trigger Event:
push
-
Statement type: