| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Unfortunately this still doesn't quite work on Windows. The callback function MyChannelProc gets called when data is available on stdin, but it seems that data is already read from stdin into the channel's internal buffer before the callback is called. If we then exit the Tcl_DoOneEvent loop return from EventHook, Python tries to read the data from stdin, but won't find anything there. See this ticket on the Tcl website for more information: https://core.tcl-lang.org/tcl/tktview/1d06180006 |
Sorry, something went wrong.
|
Closing this PR, as this approach won't work reliably on Windows (see the Tcl ticket above). Issue #140146 will need some other solution. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
When using tkinter in an interactive Python session, the EventHook function in Modules/_tkinter.c runs the Tcl/Tk event loop, and exits once data becomes available on stdin (i.e., when the user types in the next Python command).
The EventHook function monitors for input on stdin using Tcl_CreateFileHandler.
As Tcl_CreateFileHandler is Unix-only, for Windows instead the _kbhit function from Microsoft Windows is used.
However, this prevents stdin from being used with a pipe (see Issue #140146 ), as _kbhit checks for a keystroke on an actual keyboard.
This PR replaces Tcl_CreateFileHandler by Tcl_CreateChannelHandler and Tcl_GetStdChannel(TCL_STDIN), which do not depend on platform.
This has two advantages: