gh-154801: expose Tcl notifier to external event loops - #155805
Draft
BHUVANSH855 wants to merge 1 commit into
Draft
gh-154801: expose Tcl notifier to external event loops#155805BHUVANSH855 wants to merge 1 commit into
BHUVANSH855 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a draft implementation for gh-154801, which proposes exposing Tcl's external event-loop/notifier API through
_tkinter.The goal is to allow Tcl/Tk to participate in an event loop managed outside Tcl, for example a Python-level loop shared with another GUI toolkit, without requiring polling or additional threads.
This proposal has also been discussed on Discourse:
https://discuss.python.org/t/connecting-asyncio-and-tkinter-event-loops/14722/40
Current implementation
The current draft explores exposing:
Tcl_SetNotifier()through_tkinter.set_notifier()Tcl_SetServiceMode()through_tkinter.set_service_mode()Tcl_ServiceAll()through_tkinter.service_all()Tcl_QueueEvent()through_tkinter.queue_event()The basic event-queue path is working locally, and the implementation has been tested against Tcl 8.6.14.
Open design questions
This PR is intentionally a draft because the notifier/file-handler boundary still needs design feedback.
In particular, guidance would be appreciated on:
_tkinterAPI surface is appropriate;create_file_handlershould expose a Python callback object, as shown in the issue's reference implementation, rather than the current native callback representation;Tcl_QueueEvent()andTcl_ServiceAll()from_tkinter;Status
This is not ready for merge. The purpose of this draft PR is to get early maintainer feedback on the API and architecture before the remaining notifier file-handler lifetime/dispatch details are finalized.
cc @serhiy-storchaka
Refs: gh-154801