MCPcopy Index your code
hub / github.com/RustPython/RustPython / __init__

Method __init__

Lib/tkinter/__init__.py:380–408  ·  view source on GitHub ↗

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.

(self, master=None, value=None, name=None)

Source from the content-addressed store, hash-verified

378 _tclCommands = None
379
380 def __init__(self, master=None, value=None, name=None):
381 """Construct a variable
382
383 MASTER can be given as master widget.
384 VALUE is an optional value (defaults to "")
385 NAME is an optional Tcl name (defaults to PY_VARnum).
386
387 If NAME matches an existing variable and VALUE is omitted
388 then the existing value is retained.
389 """
390 # check for type of NAME parameter to override weird error message
391 # raised from Modules/_tkinter.c:SetVar like:
392 # TypeError: setvar() takes exactly 3 arguments (2 given)
393 if name is not None and not isinstance(name, str):
394 raise TypeError("name must be a string")
395 global _varnum
396 if master is None:
397 master = _get_default_root('create variable')
398 self._root = master._root()
399 self._tk = master.tk
400 if name:
401 self._name = name
402 else:
403 self._name = 'PY_VAR' + repr(_varnum)
404 _varnum += 1
405 if value is not None:
406 self.initialize(value)
407 elif not self._tk.getboolean(self._tk.call("info", "exists", self._name)):
408 self.initialize(self._default)
409
410 def __del__(self):
411 """Unset the variable in Tcl."""

Callers

nothing calls this directly

Calls 7

isinstanceFunction · 0.85
_get_default_rootFunction · 0.85
reprFunction · 0.85
_rootMethod · 0.80
initializeMethod · 0.45
getbooleanMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected