Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine what version of python3 tkinter is installed on my linux machine?

Tags:

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?

like image 636
Tom Boy Avatar asked Mar 14 '16 22:03

Tom Boy


2 Answers

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.

like image 142
McClamrock Avatar answered Sep 22 '22 18:09

McClamrock


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 
like image 36
Demian Wolf Avatar answered Sep 20 '22 18:09

Demian Wolf