This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients cheryl.sabella, terry.reedy
Date 2017-07-23.03:42:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500781349.81.0.354090879524.issue30853@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is really about managing the set of var,callback pairs. The idea of wrapping vars just clouded the issue.  

class VarTrace:
    def __init__(self):
        self.tracers = []  # or set if need to delete
    def add(self, var, callback):
        if isinstance(callback, tuple):
            callback = self.make_callback(var, callback)
        self.vartrace.add((var, callback))
        return var
    def make_callback(self, var, args):  # Used for 6 vars.
        def var_callback(*params):
            changes.add_item(*args, var.get())
        return var_callback
    def attach(self):
        for var, callback in self.tracers:
            var.trace_add('write', callback)
    def remove(cls):  # detach?
        for var, _ in self.tracers:
            var.trace_remove('write', var.trace_info()[0][1]) # doc this

# A functionalist would define a function that returns a sequence of closures.

tracers = VarTrace()

# write tests, then patch creation of tested vars, retest, patch rest.

-        self.font_name = StringVar(parent)
+        self.font_name = tracers.add(StringVar(parent), var_changed_font)
History
Date User Action Args
2017-07-23 03:42:29terry.reedysetrecipients: + terry.reedy, cheryl.sabella
2017-07-23 03:42:29terry.reedysetmessageid: <1500781349.81.0.354090879524.issue30853@psf.upfronthosting.co.za>
2017-07-23 03:42:29terry.reedylinkissue30853 messages
2017-07-23 03:42:28terry.reedycreate