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

帅比萌擦擦* 提交于 2019-12-01 23:19:45

问题


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


回答1:


Found the solution myself:

import tkinter
root = tkinter.Tk()
print(root.tk.exprstring('$tcl_library'))
print(root.tk.exprstring('$tk_library'))


来源:https://stackoverflow.com/questions/43464355/how-to-find-the-path-of-tcl-tk-library-that-tkinter-is-currently-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!