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-24.06:50:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500879007.01.0.706704745912.issue30853@psf.upfronthosting.co.za>
In-reply-to
Content
Step 1 is to add the class and then add tests.  The tests can use artificial examples.  Say 3 vars, 2 callbacks, with the 3rd done as default.  I want to start this now -- see below.  Let me know if you start working on this so we don't duplicate work. 

I just determined that calling trace_add with the same var,c pair is a bad idea.

import tkinter as tk
r = tk.Tk()
v = tk.StringVar(r)
def c(*args): print("hello", args)
print(v.trace_add('write', c))
print(v.trace_add('write', c))
v.set('a')

2545142942664c
2545153771784c
hello ('PY_VAR0', '', 'write')
hello ('PY_VAR0', '', 'write')

The class needs two lists: untraced and traced.  Attach should pop from untraced and append to traced.  The reverse for detach (remove renamed).  
One of the test tracers should increment an int var, so we can test that after calling attach twice, there is one one increment.

I will take care of looking at the doc or code to refresh my memory of why the detach is written the way it is.

Step 2, putting this in use, is a prerequisite for writing proper tests for extracted tab page classes, which are a prerequisite for putting the class in use.  So I am inclined to convert font vars when a tested class is ready and temporarily have old and new attach functions called.

We may discover a need or at least a use for other VarTrace methods when writing tests.
History
Date User Action Args
2017-07-24 06:50:07terry.reedysetrecipients: + terry.reedy, cheryl.sabella
2017-07-24 06:50:07terry.reedysetmessageid: <1500879007.01.0.706704745912.issue30853@psf.upfronthosting.co.za>
2017-07-24 06:50:07terry.reedylinkissue30853 messages
2017-07-24 06:50:06terry.reedycreate