MCPcopy Index your code
hub / github.com/python/cpython / Tk

Class Tk

Lib/tkinter/__init__.py:2510–2622  ·  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

2508
2509
2510class Tk(Misc, Wm):
2511 """Toplevel widget of Tk which represents mostly the main window
2512 of an application. It has an associated Tcl interpreter."""
2513 _w = '.'
2514
2515 def __init__(self, screenName=None, baseName=None, className='Tk',
2516 useTk=True, sync=False, use=None):
2517 """Return a new top level widget on screen SCREENNAME. A new Tcl interpreter will
2518 be created. BASENAME will be used for the identification of the profile file (see
2519 readprofile).
2520 It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
2521 is the name of the widget class."""
2522 self.master = None
2523 self.children = {}
2524 self._tkloaded = False
2525 # to avoid recursions in the getattr code in case of failure, we
2526 # ensure that self.tk is always _something_.
2527 self.tk = None
2528 if baseName is None:
2529 import os
2530 baseName = os.path.basename(sys.argv[0])
2531 baseName, ext = os.path.splitext(baseName)
2532 if ext not in ('.py', '.pyc'):
2533 baseName = baseName + ext
2534 interactive = False
2535 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
2536 if _debug:
2537 self.tk.settrace(_print_command)
2538 if useTk:
2539 self._loadtk()
2540 if not sys.flags.ignore_environment:
2541 # Issue #16248: Honor the -E flag to avoid code injection.
2542 self.readprofile(baseName, className)
2543
2544 def loadtk(self):
2545 if not self._tkloaded:
2546 self.tk.loadtk()
2547 self._loadtk()
2548
2549 def _loadtk(self):
2550 self._tkloaded = True
2551 global _default_root
2552 # Version sanity checks
2553 tk_version = self.tk.getvar('tk_version')
2554 if tk_version != _tkinter.TK_VERSION:
2555 raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)"
2556 % (_tkinter.TK_VERSION, tk_version))
2557 # Under unknown circumstances, tcl_version gets coerced to float
2558 tcl_version = str(self.tk.getvar('tcl_version'))
2559 if tcl_version != _tkinter.TCL_VERSION:
2560 raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \
2561 % (_tkinter.TCL_VERSION, tcl_version))
2562 # Create and register the tkerror and exit commands
2563 # We need to inline parts of _register here, _ register
2564 # would register differently-named commands.
2565 if self._tclCommands is None:
2566 self._tclCommands = []
2567 self.tk.createcommand('tkerror', _tkerror)

Callers 15

testFunction · 0.90
testFunction · 0.90
_is_gui_availableFunction · 0.90
_testFunction · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90
setUpClassMethod · 0.90

Calls

no outgoing calls

Tested by 15

setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72
setUpClassMethod · 0.72