Terry J. Reedy added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30853>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to