-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Add new methods to trace Tkinter variables #66313
Comments
Command used to monitor Tcl variable access ("trace variable", "trace vdelete", "trace vinfo") are deprecated and will likely be removed in a future version of Tcl. Replacements ("trace add variable", "trace remove variable", "trace info variable") use slightly different syntax (operations are specified as a list of words "array", "read", "write" and "unset" instead of a string containing characters "a", "r", "w" and "u"). Therefore we need new set of methods. Proposed preliminary patch adds trace_add, trace_remove and trace_info methods to the Variable class. It will be changed after applying bpo-22068 patch. Tests for old methods will be backported to older Python versions. |
Synchronized with the tip. |
trace_add: "list or tuple" (of such strings.) Can we say 'sequence' (or even set or iterable) or is the requirement specifically tuple or list? Does tk call the traceback function with any args it supplies(other than those passed in)? (In other words, is the callback affected by the bpo-22214 proposal?) *args is a tuple of objects, not parameters (names). I would just say "Additional arguments are passed to the traceback call". trace_remove: "Should be same as were specified in trace_add()." Is a subset not allowed to remove a subset of the registrations currently allowed? Does trying to delete other modes raise TclError? If both are so, I would say something like "Must be a subset of current trace modes.". "Additional parameters should be same as were specified in trace_add()." Alternatively, could *args (and mode) be retrieved from trace_info? trace_variable, _vdelete " This method is deprecated and will likely be removed in a future version of Tcl." Slightly more accurate would be "This deprecated method wraps a deprecated tcl method that will likely be removed in the future." |
No. The call() method accepted only tuples, and since bpo-21525 it now
Tcl calls the traceback function with stringified arguments. No, this is not
Unfortunately both are no. If you pass wrong mode, trace_remove() will
Same bad things as when pass wrong mode.
Looks good.
You can retrieve mode, cbname and (stringified) args from trace_info. Currently for mode, cbname_args in v.trace_info():
v.trace_remove(mode, *cbname_args) With next patch '*' is not needed. Thank you for the review. Updated patch addresses all your comments. |
Updated patch provides simplified interface. The support of passing callback arguments is removed. This complicates an interface and is not needed since Python supports closure and the support of callback arguments was more limited (supported only limited set of types and arguments are converted to str). Added an entry in What's News. |
I gather that 'add', 'delete', and 'info' replace 'variable', 'vdelete', and 'vinfo'. Also see review. Deprecation period should be fairly long. Of course, a currently hypothetical tcl/tk 9.0 with old stuff gone would make it immediate for users of 9.0. Applies cleanly and tests pass, but do not hardly interact with the patch. More importantly, IDLE starts fresh, option dialog comes up and appears to work. So old functions continue to work. The real test from IDLE would be to recode configdialog to use the new functions and then test. I am thinking about how to test configdialog enough that I am willing to refactor it for real. |
Thank you for your review Terry. Here is updated patch. IDLE now uses new API. |
What's New: patchcheck found trailing whitespace to remove; it contains some additions that appear to belong to another issue. configdialog change looks good and dialog still works. I am expecting to add more Vars sometime soon, though probably not in the next few days. Before I do, I want to reduce the repetition of names and remove the repetition of trace_add calls. I just opened bpo-27388. |
Maybe omit the mention of the array mode since it can't be used with variables created with Tkinter wrapper? |
Good idea. Anyone who knows enough to create one by calling into tcl, assuming that is possible, should know that the methods apply. Everyone else, like me, will just be confused. |
New changeset a201180c0f77 by Serhiy Storchaka in branch 'default': |
New changeset 77378dce6bcf by Serhiy Storchaka in branch '2.7': New changeset 293ec9547334 by Serhiy Storchaka in branch '3.5': New changeset c4839c36a71f by Serhiy Storchaka in branch 'default': |
Backported fixes for old tracing methods. Unfortunately the tracing in the "u" mode doesn't work in 2.7. This is related to some differences in GC. I don't think this is important and close this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: