Home > Back-end >  Tkinter winfo_interps always empty
Tkinter winfo_interps always empty

Time:10-08

Why does winfo_interps always return an empty tuple ?

The documentation states:

Returns a list whose members are the names of all Tcl interpreters (e.g. all Tk-based applications) currently registered for a particular display. If the -displayof option is given then the return value refers to the display of window; otherwise it refers to the display of the application's main window.

and the source code is:

def winfo_interps(self, displayof=0):
    """Return the name of all Tcl interpreters for this display."""
    args = ('winfo', 'interps')   self._displayof(displayof)
    return self.tk.splitlist(self.tk.call(args))

While displayof and splitlist works in other calls, this one wont work. I assume it is related to the tcl interpreter. I'm running the following code under Windows 11 in python 3.10 and tkinter 8.6.12

import tkinter as tk

root = tk.Tk()
inps = tk.Tcl()
print(root.winfo_interps())
root.mainloop()

CodePudding user response:

The value is indeed always empty on Windows. This is correct; the IPC mechanism that sits behind it is not supported on that platform (for a mixture of technical and historic policy reasons relating to the state of Windows's security a few decades ago). There are various alternative solutions (such as OLE or COM or something based on sockets), but none are enabled by default and all are a bit annoying when it comes to discovery. I don't know the space of Python solutions for this very well.

  • Related