Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?
In Python 3, it's tkinter
with a small t
, and you need to import it. Thus:
>>> import tkinter >>> tkinter.TkVersion 8.6
If you didn't import it, you'd get the error you mentioned.
Previous answers describe tkinter.TclVersion
and tkinter.TkVersion
, which are good for getting the major and minor Tcl/Tk version numbers. However, they don't give the patch version, which is also necessary for many cases.
To get the full version (in the major.minor.patch
format), you can use the info patchlevel
Tcl command instead.
First, start a Tcl interpreter instance.
You can create a Tcl interpreter instance (without Tk) using tkinter.Tcl()
.
import tkinter tcl = tkinter.Tcl() print(tcl.call("info", "patchlevel")) # Output: # 8.6.10
You may also need to get the full Tcl/Tk version from a Tkinter-based application. Since tkinter.Tk()
already has an associated Tcl interpreter, you can execute the info patchlevel
command in it.
import tkinter root = tkinter.Tk() ... print(root.tk.call("info", "patchlevel")) # Output: # 8.6.10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With