(self, master=None, value=None, name=None)
Construct a variable

        MASTER can be given as master widget.
        VALUE is an optional value (defaults to "")
        NAME is an optional Tcl name (defaults to PY_VARnum).

        If NAME matches an existing variable and VALUE is omitted
        then the existing value is retained.
Construct a variable
Construct a variable
def __init__(self, master=None, value=None, name=None):
        """Construct a variable

        MASTER can be given as master widget.
        VALUE is an optional value (defaults to "")
        NAME is an optional Tcl name (defaults to PY_VARnum).

        If NAME matches an existing variable and VALUE is omitted
        then the existing value is retained.
        """
        # check for type of NAME parameter to override weird error message
        # raised from Modules/_tkinter.c:SetVar like:
        # TypeError: setvar() takes exactly 3 arguments (2 given)
        if name is not None and not isinstance(name, str):
            raise TypeError("name must be a string")
        global _varnum
        if master is None:
            master = _get_default_root('create variable')
        self._root = master._root()
        self._tk = master.tk
        if name:
            self._name = name
        else:
            self._name = 'PY_VAR' + repr(_varnum)
            _varnum += 1
        if value is not None:
            self.initialize(value)
        elif not self._tk.getboolean(self._tk.call("info", "exists", self._name)):
            self.initialize(self._default)
def __init__ ( self , master = None , value = None , name = None ) : # check for type of NAME parameter to override weird error message # raised from Modules/_tkinter.c:SetVar like: # TypeError: setvar() takes exactly 3 arguments (2 given) if name is not None and not isinstance ( name , str ) : raise TypeError ( "name must be a string" ) global _varnum if master is None : master = _get_default_root ( 'create variable' ) self . _root = master . _root ( ) self . _tk = master . tk if name : self . _name = name else : self . _name = 'PY_VAR' + repr ( _varnum ) _varnum += 1 if value is not None : self . initialize ( value ) elif not self . _tk . getboolean ( self . _tk . call ( "info" , "exists" , self . _name ) ) : self . initialize ( self . _default )