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.

classification
Title: Variable.__init__ uses self.set(), blocking specialization
Type: Stage:
Components: Tkinter Versions: Python 2.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: loewis Nosy List: droun, loewis, terry.reedy
Priority: normal Keywords:

Created on 2005-04-07 21:20 by droun, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg24963 - (view) Author: Emil (droun) Date: 2005-04-07 21:20
in class Variable the constructor uses self.set() to set 
the value of the variable. This makes it hard and in some 
cases impossible to make a speciallization of Variable 
that performs some operation after changing the value. It 
would be preferable to use Tkinter.Variable.set(self, 
self._default)

example:

class ViewChanger(Tkinter.StringVar) :

    def __init__(self, views) :
        self.views = views
        Tkinter.StringVar.__init__(self)

    def set(self, newview) :
        self.views.activate(newview)
        Tkinter.StringVar.set(newview)

get() and everything else will use the normal StringVar 
ipementation, but when the value is changed, a new view 
is activated.
At creation here the self.views varaible will be accessed, 
method activate() will be called, and it might not even be 
fully initiallized yet. This is the normal case if you want 
to supply a variable to a widget, where a variable change 
may update the widget. 
msg24964 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2005-04-26 21:46
Logged In: YES 
user_id=593130

Duplicate of 1178863
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41827
2005-04-07 21:20:59drouncreate