Skip to content

Commit c8f3bca

Browse files
committed
start documenting contents
1 parent 6a7f4e8 commit c8f3bca

File tree

1 file changed

+138
-21
lines changed

1 file changed

+138
-21
lines changed

Doc/library/tkinter.rst

Lines changed: 138 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ toolkits, doesn't provide a blocking event loop.
106106
Instead, Tcl code is supposed to pump the event queue regularly at strategic
107107
moments -- after an action that triggers an event, before a later action that
108108
needs the result of that event. As such, all Tcl commands are designed to work
109-
without an event loop running, only event handlers will not be executed
109+
without an event loop running -- only event handlers will not be executed
110110
until the queue is processed. This allows to work completely in one thread,
111111
i.e. even in environments that have no thread support at all.
112112

@@ -118,21 +118,22 @@ predefined "event handler".
118118
Likewise, for any lengthy tasks, the UI thread can launch worker threads that
119119
report back on their progress via the same event queue.
120120

121-
Tkinter gives the best of both worlds. It presents the "modern" multithreaded
122-
GUI model as the primary mode of execution while retaining the freedom and
123-
flexibility of Tcl's one. Any calls can be made from any threads, only
124-
subject to Tcl's architectural restictions:
121+
Tkinter strives to provide the best of both worlds. The "moderm" multithreaded
122+
GUI model is the primary mode of execution, but pumping messages manually
123+
instead is also supported. What is more important, any Tkinter calls can be
124+
made from any Python threads, only subject to Tcl's architectural restictions:
125125

126-
* For nonthreaded Tcl, all Tcl calls are wrapped with a global lock. So,
127-
any calls can be made from any threads, but under the hood, only one
128-
is active at a time.
126+
* A nonthreaded Tcl doesn't know anything about threads, so all Tcl calls are
127+
wrapped with a global lock to enforce sequential access.
128+
Any Tkinter calls can be made from any threads, but under the hood, only one
129+
is active at any moment.
129130

130131
* A threaded Tcl interpreter instance, when created, becomes tied to the
131132
creating OS thread ("the interpreter thread"). Tcl mandates that all calls
132-
to the instance must come from this thread, except special inter-thread
133+
to the instance must come from this thread, save for special inter-thread
133134
communication APIs. Tkinter implements calls from outside the interpreter
134-
thread by posting an event to the interpreter's queue that would run the
135-
necessary commands, then waits for result. As such:
135+
thread by posting an event to the interpreter's queue, then waits for the
136+
result of its processing. As such:
136137

137138
* To make calls from outside the interpreter queue, :func:`mainloop`
138139
must be running in the interpreter queue. Otherwise, a
@@ -144,24 +145,140 @@ subject to Tcl's architectural restictions:
144145
Module contents
145146
---------------
146147

147-
.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=1)
148-
149-
The :class:`Tk` class is instantiated without arguments. This creates a toplevel
150-
widget of Tk which usually is the main window of an application. Each instance
151-
has its own associated Tcl interpreter.
152-
153-
.. FIXME: The following keyword arguments are currently recognized:
154148

149+
.. attribute:: TclVersion
150+
.. attribute:: TkVersion
155151

152+
Tcl and Tk library versions used, as floating-point numbers
153+
154+
156155
.. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
157156

158-
The :func:`Tcl` function is a factory function which creates an object much like
159-
that created by the :class:`Tk` class, except that it does not initialize the Tk
160-
subsystem. This is most often useful when driving the Tcl interpreter in an
157+
A factory function which creates an instance of the :class:`Tk` class,
158+
except that it sets `useTk` to `0` by default, thus not creating a top-level
159+
widget. This is useful when driving the Tcl interpreter in an
161160
environment where one doesn't want to create extraneous toplevel windows, or
162161
where one cannot (such as Unix/Linux systems without an X server). An object
163162
created by the :func:`Tcl` object can have a Toplevel window created (and the Tk
164163
subsystem initialized) by calling its :meth:`loadtk` method.
164+
All arguments are the same as in `Tk` constructor.
165+
166+
167+
.. class:: TclError
168+
169+
An exception raised for an error returned by a Tcl interpreter.
170+
171+
172+
.. attribute:: wantobjects = 1
173+
174+
Whether Tcl call results in new Tk objects should be converted from Tcl
175+
types to Python types. An integer, any nonzero value means "true".
176+
If not set, string representations of Tcl objects are returned.
177+
178+
179+
.. attribute:: READABLE
180+
.. attribute:: WRITABLE
181+
.. attribute:: EXCEPTION
182+
183+
Constants used for the *mask* parameter of :func:`createfilehandler`.
184+
185+
186+
.. class:: EventType
187+
188+
A enumeration of known
189+
`Tk event types <https://www.tcl.tk/man/tcl8.6/TkCmd/bind.htm#M7>`_,
190+
used for :attr:`Event`'s *type* attribute.
191+
192+
193+
.. class:: Event
194+
195+
Container for the properties of a Tcl event.
196+
197+
If a callback function is registered using :func:`bind`,
198+
:func:`bind_all`, :func:`bind_class`, or :func:`tag_bind`,
199+
the callback is called with an :class:`Event` as the first argument.
200+
201+
Will have the same fields as the corresponding
202+
`Tk event`<https://www.tcl.tk/man/tcl8.6/TkCmd/event.htm#M9>`_
203+
plus a *type* field that will contain an :class:`EventType`
204+
or a string with a number as returned by Tcl if the event type is unknown.
205+
206+
207+
.. function:: NoDefaultRoot()
208+
209+
Unset the current default root widget and do not use newly-created
210+
:class:`Tk` instances to set it.
211+
212+
By default, the first :class:`Tk` created when the default root is unset
213+
becomes the default root, and stays it until it's destroyed. Whenever a
214+
:class:`Widget` or other entity that requires a parent/master widget
215+
is created, and that parent is not specified, the default root is used.
216+
If the default root is not set, such a call will fail.
217+
218+
219+
.. class:: Variable(master=None, value=None, name=None)
220+
221+
Represent a Tcl global variable bound to *master* widget's value via the
222+
`textVariable option
223+
<https://www.tcl.tk/man/tcl8.6/TkCmd/options.htm#M-textvariable>`_.
224+
225+
*master* is the widget to bind the variable to.
226+
*value* is an optional initial value
227+
228+
StringVar
229+
IntVar
230+
DoubleVar
231+
BooleanVar
232+
mainloop
233+
getint
234+
getdouble
235+
getboolean
236+
Misc
237+
CallWrapper
238+
XView
239+
YView
240+
Wm
241+
Tk
242+
Tcl
243+
Pack
244+
Place
245+
Grid
246+
BaseWidget
247+
Widget
248+
Toplevel
249+
Button
250+
Canvas
251+
Checkbutton
252+
Entry
253+
Frame
254+
Label
255+
Listbox
256+
Menu
257+
Menubutton
258+
Message
259+
Radiobutton
260+
Scale
261+
Scrollbar
262+
Text
263+
OptionMenu
264+
Image
265+
PhotoImage
266+
BitmapImage
267+
image_names
268+
image_types
269+
Spinbox
270+
LabelFrame
271+
PanedWindow
272+
273+
.. class:: Tk(screenName=None, baseName=None, className='Tk', useTk=1)
274+
275+
The :class:`Tk` class encapsulates is instantiated without arguments. This creates a toplevel
276+
widget of Tk which usually is the main window of an application. Each instance
277+
has its own associated Tcl interpreter.
278+
279+
.. FIXME: The following keyword arguments are currently recognized:
280+
281+
165282
166283
167284
Other modules that provide Tk support include:

0 commit comments

Comments
 (0)