Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: can we specify a specific TclTk event loop to pass to twisted.internet.tksupport.install ? #12100

Open
MacDaddy1660B opened this issue Jan 31, 2024 · 2 comments

Comments

@MacDaddy1660B
Copy link

MacDaddy1660B commented Jan 31, 2024

Is your feature request related to a problem? Please describe.
The tksupport.install method calls widget.update(). The Tcl_UpdateObjCmd function, i.e. the update command in Tcl or Python's widget.update() is known to cause problems in complex TclTk applications and its use is generally ill-advised.

Describe the solution you'd like
Can we pass any tkinter event loop to tksupport.install, instead of it needing to use update? For example, it'd be nice to make a call as follows:

widget = tkinter.Tk()
twisted.internet.tksupport.install( widget.tk.dooneevent, ms=ms )

Or, for example, for even more control over the types of events we'd like to process, or to control how the loop behaves:

twisted.internet.tksupport.install( widget.tk.dooneevent, tkinter._tkinter.FILE_EVENTS | tkinter._tkinter.DONT_WAIT, ms=ms)

With any of the flags or'ed together.

Or if update is preferred, widget.update can be passed directly.

Describe alternatives you've considered
the Tcl update command doesn't appear to accept the TCL_DONT_WAIT flag, which can cause the application to get stuck in the Tcl_UpdateObjCmd loop. In addition, it doesn't afford us any control over the types of events update will process, except for when we use the idletasks option.

Additional context
My reason for asking is that my Twisted application seems to hang the TCL_UpdateObjCmd event loop when update is called, leading to a nested-eventloop condition that TclTk is unable to break out of. The application hangs with no hope of recovering it.

Thanks for your consideration.

@glyph
Copy link
Member

glyph commented Jan 31, 2024

+1 to this. In principle, every foreign event loop reactor should support the maximum customization of the native loop, and not make any default assumptions.

@MacDaddy1660B
Copy link
Author

Well in that case :-D, it'd be great if we could pass widget.mainloop to install, but I don't see a clear way of going about doing that in Twisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants