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

1

5

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.)

Cap answered 18/4, 2017 at 5:35 Comment(0)
C
11

Found the solution myself:

import tkinter
root = tkinter.Tk()
print(root.tk.exprstring('$tcl_library'))
print(root.tk.exprstring('$tk_library'))
Cap answered 18/4, 2017 at 6:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.