bpo-13553: Document tkinter.Tk args (#4786) · python/cpython@c56e2bb (original) (raw)

`@@ -124,16 +124,72 @@ the modern themed widget set and API::

`

124

124

` from tkinter import ttk

`

125

125

``

126

126

``

127

``

`-

.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=1)

`

128

``

-

129

``

`` -

The :class:Tk class is instantiated without arguments. This creates a toplevel

``

130

``

`-

widget of Tk which usually is the main window of an application. Each instance

`

131

``

`-

has its own associated Tcl interpreter.

`

132

``

-

133

``

`-

.. FIXME: The following keyword arguments are currently recognized:

`

134

``

-

135

``

-

136

``

`-

.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=0)

`

``

127

`+

.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=True, sync=False, use=None)

`

``

128

+

``

129

`+

Construct a toplevel Tk widget, which is usually the main window of an

`

``

130

`+

application, and initialize a Tcl interpreter for this widget. Each

`

``

131

`+

instance has its own associated Tcl interpreter.

`

``

132

+

``

133

`` +

The :class:Tk class is typically instantiated using all default values.

``

``

134

`+

However, the following keyword arguments are currently recognized:

`

``

135

+

``

136

`+

screenName

`

``

137

`` +

When given (as a string), sets the :envvar:DISPLAY environment

``

``

138

`+

variable. (X11 only)

`

``

139

`+

baseName

`

``

140

`+

Name of the profile file. By default, baseName is derived from the

`

``

141


 program name (``sys.argv[0]``).

``

142

`+

className

`

``

143

`+

Name of the widget class. Used as a profile file and also as the name

`

``

144

`+

with which Tcl is invoked (argv0 in interp).

`

``

145

`+

useTk

`

``

146


 If ``True``, initialize the Tk subsystem. The :func:`tkinter.Tcl() <Tcl>`

``

147


 function sets this to ``False``.

``

148

`+

sync

`

``

149


 If ``True``, execute all X server commands synchronously, so that errors

``

150

`+

are reported immediately. Can be used for debugging. (X11 only)

`

``

151

`+

use

`

``

152

`+

Specifies the id of the window in which to embed the application,

`

``

153

`+

instead of it being created as an independent toplevel window. id must

`

``

154

`+

be specified in the same way as the value for the -use option for

`

``

155

`+

toplevel widgets (that is, it has a form like that returned by

`

``

156

`` +

:meth:winfo_id).

``

``

157

+

``

158

`+

Note that on some platforms this will only work correctly if id refers

`

``

159

`+

to a Tk frame or toplevel that has its -container option enabled.

`

``

160

+

``

161

`` +

:class:Tk reads and interprets profile files, named

``

``

162

`` +

:file:.{className}.tcl and :file:.{baseName}.tcl, into the Tcl

``

``

163

`` +

interpreter and calls :func:exec on the contents of

``

``

164

`` +

:file:.{className}.py and :file:.{baseName}.py. The path for the

``

``

165

`` +

profile files is the :envvar:HOME environment variable or, if that

``

``

166

`` +

isn't defined, then :attr:os.curdir.

``

``

167

+

``

168

`+

.. attribute:: tk

`

``

169

+

``

170

`` +

The Tk application object created by instantiating :class:Tk. This

``

``

171

`+

provides access to the Tcl interpreter. Each widget that is attached

`

``

172

`` +

the same instance of :class:Tk has the same value for its :attr:tk

``

``

173

`+

attribute.

`

``

174

+

``

175

`+

.. attribute:: master

`

``

176

+

``

177

`` +

The widget object that contains this widget. For :class:Tk, the

``

``

178

`` +

master is :const:None because it is the main window. The terms

``

``

179

`+

master and parent are similar and sometimes used interchangeably

`

``

180

`` +

as argument names; however, calling :meth:winfo_parent returns a

``

``

181

`` +

string of the widget name whereas :attr:master returns the object.

``

``

182

`+

parent/child reflects the tree-like relationship while

`

``

183

`+

master/slave reflects the container structure.

`

``

184

+

``

185

`+

.. attribute:: children

`

``

186

+

``

187

`` +

The immediate descendants of this widget as a :class:dict with the

``

``

188

`+

child widget names as the keys and the child instance objects as the

`

``

189

`+

values.

`

``

190

+

``

191

+

``

192

`+

.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=False)

`

137

193

``

138

194

`` The :func:Tcl function is a factory function which creates an object much like

``

139

195

`` that created by the :class:Tk class, except that it does not initialize the Tk

``