tkinter-videoplayer
A simple video player component for Tkinter, built with OpenCV and Pillow.
The current alternatives either didn't work (outdated dependencies) or used av (which requires compilation).
Features
- Batteries included: Includes controls to play, pause, stop, and seek video files
- Familiar UI: Toggle play/pause with a button or click or spacebar
- Easy to install: Doesn't use
av(which requires compilation on the host system) - Looks decent visually, and can be customized in
theme.py - Works by rendering frames using OpenCV and Pillow
Screenshot
Installation
pip install tkinter-videoplayer
Quick Start
from tkinter_videoplayer import VideoPlayer
import tkinter as tk
root = tk.Tk()
player = VideoPlayer(root, video_path='sample.mp4', height=360)
root.mainloop()
API
VideoPlayer(parent, video_path, **options)
parent: Tkinter parent widgetvideo_path: Path to the video file**options: Additional options to customize the player:autoplay(bool): Start playback automatically when loaded. Default:False.loop(bool): Loop the video when it reaches the end. Default:False.controls(bool): Show playback controls (play, pause, seek, etc.). Default:True.width(int): Width of the video player in pixels. Default: video width or parent width.height(int): Height of the video player in pixels. Default: video height or parent height.
You can also edit the default theme by modifying theme.py.
Methods
play(): Start or resume playbackpause(): Pause playbackstop(): Stop playback and reset
Properties
autoplay(bool): Whether playback starts automatically when loaded.loop(bool): Whether playback loops when the video ends.controls(bool): Whether playback controls are shown.currentTime(float): Current playback time in seconds (get/set).duration(float): Duration of the loaded video in seconds (read-only).
Events
play: Called when playback startspause: Called when playback pausesended: Called when playback endsload: Called when the video loads
Usage Example
See the examples folder for more examples!
- 01_combined_examples.py: Shows four different video player configurations in a single 2x2 grid window, each with a title, video, and code snippet.
- 02_events.py: Demonstrates how to use event listeners for play, pause, and end events.
- 03_external_controls.py: Shows how to control the video player externally with custom buttons.
# Example: Basic usage
from tkinter_videoplayer import VideoPlayer
import tkinter as tk
root = tk.Tk()
player = VideoPlayer(root, video_path='sample.mp4', height=360)
player.frame.pack()
root.mainloop()
# Example: Adding event listeners (see 02_events.py)
def handle_play():
print("Video started!")
def handle_pause():
print("Video paused.")
def handle_ended():
print("Video ended.")
player.add_event_listener("play", handle_play)
player.add_event_listener("pause", handle_pause)
player.add_event_listener("ended", handle_ended)
# Example: External controls (see 03_external_controls.py)
btn_play = tk.Button(root, text="Play", command=player.play)
btn_pause = tk.Button(root, text="Pause", command=player.pause)
btn_stop = tk.Button(root, text="Stop", command=player.stop)
btn_play.pack()
btn_pause.pack()
btn_stop.pack()
Metadata
Release files for tkinter-videoplayer 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tkinter_videoplayer-1.3.1.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tkinter_videoplayer-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.0 kB
Release files / tkinter_videoplayer-1.3.1.tar.gz
| Download URL | tkinter_videoplayer-1.3.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f2c53ee66c155757b81ba36b2af45b4a51993c3892ebe39a80b2ac8e4ee41b7
|
|
BLAKE2b-256 checksum How to use checksums |
c0b116709e1fbb0172446e4e0808edefac7f55353a0261c37ce3871595022be1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2025.
Transparency logRelease files / tkinter_videoplayer-1.3.1-py3-none-any.whl
| Download URL | tkinter_videoplayer-1.3.1-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1936f7e6b9c197c3326007abfb18dad1ceb228b131f15f9e2f40d3eb0f469f0
|
|
BLAKE2b-256 checksum How to use checksums |
bdbb9d5b4db5ad4f67fa18f6122608253c78c9c326a34f1701fab6bf4630f91f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2025.
Transparency log