Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the path of Tcl/Tk library that Tkinter is currently using?

TCL_LIBRARY and TK_LIBRARY environment variables can be used to bind Tkinter with proper Tcl/Tk installation.

How to get the location of Tcl/Tk from working Tkinter instance?

(I'm running a frontend in non-virtual Python with working Tkinter and I need to run a tkinter subprocess in a virtual environment. Virtual Python doesn't find Tcl/Tk. I can specify TCL_LIBRARY and TK_LIBRARY manually, but I'd like to have more general solution and extract this information from the parent process.)

like image 906
Aivar Avatar asked Apr 18 '17 05:04

Aivar


People also ask

How do you check tkinter is installed or not?

Running python -m tkinter from the command line should open a window demonstrating a simple Tk interface, letting you know that tkinter is properly installed on your system, and also showing what version of Tcl/Tk is installed, so you can read the Tcl/Tk documentation specific to that version.

What does root Tk () do in tkinter?

In order to create a tkinter application, we generally create an instance of tkinter frame, i.e., Tk(). It helps to display the root window and manages all the other components of the tkinter application. We can initialize the tkinter instance by assigning the variable to it.

How do you call a Tcl script in Python?

As Tcl is a string-interpreted language where everything is a string, evaluating Tcl calls within Python is effectively the same as evaluating a string object containing Tcl code using the interpreter's eval() function.

What is Tk () in tkinter Python?

The tkinter package (“Tk interface”) is the standard Python interface to the Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, as well as on Windows systems. (Tk itself is not part of Python; it is maintained at ActiveState.)


1 Answers

Found the solution myself:

import tkinter
root = tkinter.Tk()
print(root.tk.exprstring('$tcl_library'))
print(root.tk.exprstring('$tk_library'))
like image 171
Aivar Avatar answered Sep 21 '22 18:09

Aivar