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: enhancement Stage: test needed
Components: Tkinter Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gpolo Nosy List: ajaksu2, asvetlov, droun, gpolo, loewis, python-dev
Priority: normal Keywords: patch

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

Files
File name Uploaded Description Edit
tk.patch asvetlov, 2012-03-12 23:53 review
Messages (4)
msg60719 - (view) Author: Emil (droun) Date: 2005-04-07 21:01
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. 
msg82174 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-15 22:16
Code is still as described in trunk rev69546.
msg155545 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-13 00:47
New changeset 79bb99ec2464 by Martin v. Löwis in branch 'default':
Issue #1178863: Separate initialisation from setting when initializing
http://hg.python.org/cpython/rev/79bb99ec2464
msg155633 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-03-13 16:44
Thanks for the patch.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41826
2012-03-13 16:44:59loewissetstatus: open -> closed
resolution: fixed
messages: + msg155633
2012-03-13 00:47:47python-devsetnosy: + python-dev
messages: + msg155545
2012-03-12 23:54:04asvetlovsetnosy: + asvetlov
2012-03-12 23:53:44asvetlovsetfiles: + tk.patch
keywords: + patch
versions: + Python 3.3, - Python 3.2
2010-08-21 13:41:19BreamoreBoysetassignee: loewis -> gpolo

nosy: + gpolo
versions: + Python 3.2, - Python 2.7
2009-02-15 22:16:03ajaksu2setnosy: + ajaksu2
stage: test needed
type: enhancement
messages: + msg82174
versions: + Python 2.7, - Python 2.4
2005-04-07 21:01:52drouncreate