tkinter-gl
raw JSON → 1.1 verified Mon Apr 27 auth: no python
A base class for GL rendering surfaces in tkinter, enabling OpenGL integration with Tkinter GUIs. Current version 1.1, supports Python >=3.8. Low release cadence.
pip install tkinter-gl Common errors
error ImportError: cannot import name 'GLCanvas' from 'tkinter_gl' ↓
cause Installed version is older than 1.0 (if any) or package not installed.
fix
Ensure you have installed tkinter-gl (pip install tkinter-gl) and the correct import is from tkinter_gl import GLCanvas.
error ModuleNotFoundError: No module named 'OpenGL' ↓
cause PyOpenGL is not installed.
fix
Install PyOpenGL: pip install PyOpenGL
Warnings
gotcha GLCanvas may not work on ARM Macs without proper PyOpenGL installation. Use pip install PyOpenGL PyOpenGL_accelerate. ↓
fix Install PyOpenGL with compatible wheel for ARM.
gotcha On Linux, GLCanvas may require the Tkinter window to be realized before OpenGL calls work. Ensure you call root.update() or wait for the window to appear. ↓
fix Add root.update() after creating the canvas but before making GL calls.
Imports
- GLCanvas wrong
from tkinter_gl import Canvascorrectfrom tkinter_gl import GLCanvas
Quickstart
import tkinter as tk
from tkinter_gl import GLCanvas
root = tk.Tk()
canvas = GLCanvas(root, width=400, height=400)
canvas.pack()
root.mainloop()