[ python-Bugs-1178872 ] Variable.__init__ uses self.set(), blocking specialization

SourceForge.net noreply at sourceforge.net
Thu Apr 7 23:20:59 CEST 2005


Bugs item #1178872, was opened at 2005-04-07 23:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1178872&group_id=5470

Category: Tkinter
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Emil (droun)
Assigned to: Martin v. Löwis (loewis)
Summary: Variable.__init__ uses self.set(), blocking specialization

Initial Comment:
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. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1178872&group_id=5470


More information about the Python-bugs-list mailing list