Title: Add tkinter support for Tcl channels · Issue #162537 · python/cpython · GitHub
Open Graph Title: Add tkinter support for Tcl channels · Issue #162537 · python/cpython
X Title: Add tkinter support for Tcl channels · Issue #162537 · python/cpython
Description: tkinter can register a callback to run from the Tk mainloop when a file descriptor becomes readable or writable, via tk.createfilehandler() / tk.deletefilehandler(). But these wrap Tcl_CreateFileHandler, which is not implemented on Windo...
Open Graph Description: tkinter can register a callback to run from the Tk mainloop when a file descriptor becomes readable or writable, via tk.createfilehandler() / tk.deletefilehandler(). But these wrap Tcl_CreateFileHa...
X Description: tkinter can register a callback to run from the Tk mainloop when a file descriptor becomes readable or writable, via tk.createfilehandler() / tk.deletefilehandler(). But these wrap Tcl_CreateFileHa...
Opengraph URL: https://github.com/python/cpython/issues/162537
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add tkinter support for Tcl channels","articleBody":"tkinter can register a callback to run from the Tk mainloop when a file descriptor becomes readable or writable, via `tk.createfilehandler()` / `tk.deletefilehandler()`. But these wrap `Tcl_CreateFileHandler`, which is not implemented on Windows, so there is no portable way to do asynchronous I/O on a file, pipe or socket inside the Tk event loop.\n\nTcl's channel API (`Tcl_MakeFileChannel`, `Tcl_CreateChannelHandler`) works on all platforms. I propose exposing it in tkinter.\n\nA new method creates a channel from a file, a pipe or a socket:\n\n```python\nchannel = widget.tk.createchannel(file, mode='r')\n```\n\n* *file* is an object with a `fileno()` method (a file or socket) or an integer file descriptor.\n* *mode* is `'r'`, `'w'` or `'rw'`.\n* The channel duplicates the descriptor/handle/socket, so closing the channel does not close the original, and vice versa.\n* The channel is binary and non-blocking.\n\nIt returns a `tkchannel` object:\n\n* `read(size=-1)` — read up to *size* bytes; `b''` at end of file, `None` if nothing is available.\n* `write(data)` — write a bytes-like object.\n* `flush()`, `eof()`, `close()`.\n* `createhandler(mask, func)` / `deletehandler()` — call `func(channel, mask)` when the channel becomes readable or writable, where *mask* ORs `tkinter.READABLE` and `tkinter.WRITABLE`.\n* `name` — the Tcl channel name, usable from Tcl commands and options that take a channel, such as the *channel* option of `Canvas.postscript()`.\n* `closed`.\n\nIt is also a context manager that closes the channel on exit.\n\nThis complements the existing file handlers (which stay as the thin Unix-only wrapper) and overlaps in spirit with gh-154801 (exposing more of Tcl's event-loop API).\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162538\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-11-24T09:37:56Z","url":"https://github.com/python/cpython/issues/162537"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e2755c4d-38c9-90b1-98a8-c17a298e7937 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0EA:39588:E6F3DC:134C9D3:6B064C06 |
| html-safe-nonce | d16d8e0d9104c2aa18c6881489ece158c0bba9cc08767f7c7b6882cc156da244 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEVBOjM5NTg4OkU2RjNEQzoxMzRDOUQzOjZCMDY0QzA2IiwidmlzaXRvcl9pZCI6IjU2ODA1MjczNjgxNDI2MDUzMTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 236e3daafc6bd67c359b49abaa4a575a914d01db9964d839c77179406c1c8c62 |
| hovercard-subject-tag | issue:6578863997 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/162537/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f7a055a981290272191f081286b0c66d5c075f2fed651de10d85b0c9d112197/python/cpython/issues/162537 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f7a055a981290272191f081286b0c66d5c075f2fed651de10d85b0c9d112197/python/cpython/issues/162537 |
| og:image:alt | tkinter can register a callback to run from the Tk mainloop when a file descriptor becomes readable or writable, via tk.createfilehandler() / tk.deletefilehandler(). But these wrap Tcl_CreateFileHa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width