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

Class Tk

Lib/tkinter/__init__.py:2434–2548  ·  view source on GitHub ↗

Toplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.

Source from the content-addressed store, hash-verified

2432
2433
2434class Tk(Misc, Wm):
2435 """Toplevel widget of Tk which represents mostly the main window
2436 of an application. It has an associated Tcl interpreter."""
2437 _w = '.'
2438
2439 def __init__(self, screenName=None, baseName=None, className='Tk',
2440 useTk=True, sync=False, use=None):
2441 """Return a new top level widget on screen SCREENNAME. A new Tcl interpreter will
2442 be created. BASENAME will be used for the identification of the profile file (see
2443 readprofile).
2444 It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
2445 is the name of the widget class."""
2446 self.master = None
2447 self.children = {}
2448 self._tkloaded = False
2449 # to avoid recursions in the getattr code in case of failure, we
2450 # ensure that self.tk is always _something_.
2451 self.tk = None
2452 if baseName is None:
2453 import os
2454 # TODO: RUSTPYTHON
2455 # baseName = os.path.basename(sys.argv[0])
2456 baseName = "" # sys.argv[0]
2457 baseName, ext = os.path.splitext(baseName)
2458 if ext not in ('.py', '.pyc'):
2459 baseName = baseName + ext
2460 interactive = False
2461 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
2462 if _debug:
2463 self.tk.settrace(_print_command)
2464 if useTk:
2465 self._loadtk()
2466 if not sys.flags.ignore_environment:
2467 # Issue #16248: Honor the -E flag to avoid code injection.
2468 self.readprofile(baseName, className)
2469
2470 def loadtk(self):
2471 if not self._tkloaded:
2472 self.tk.loadtk()
2473 self._loadtk()
2474
2475 def _loadtk(self):
2476 self._tkloaded = True
2477 global _default_root
2478 # Version sanity checks
2479 tk_version = self.tk.getvar('tk_version')
2480 if tk_version != _tkinter.TK_VERSION:
2481 raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)"
2482 % (_tkinter.TK_VERSION, tk_version))
2483 # Under unknown circumstances, tcl_version gets coerced to float
2484 tcl_version = str(self.tk.getvar('tcl_version'))
2485 if tcl_version != _tkinter.TCL_VERSION:
2486 raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \
2487 % (_tkinter.TCL_VERSION, tcl_version))
2488 # Create and register the tkerror and exit commands
2489 # We need to inline parts of _register here, _ register
2490 # would register differently-named commands.
2491 if self._tclCommands is None:

Callers 7

testFunction · 0.90
_is_gui_availableFunction · 0.90
_get_default_rootFunction · 0.85
_get_temp_rootFunction · 0.85
TclFunction · 0.85
_testFunction · 0.85
testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected