Linguistics 408/508 |
Fall 2003 |
Hammond |
Handout 20
Overview
- Questions from last time
- Working with
Tk
continued
Working with Tk
continued
-
pack()
. Widgets are placed in the
window with the pack()
command. The
position of widgets is controlled by
when they are packed, and by the
properties that are passed to the
pack()
command (example,
example, example).
-
pack()
attributes. We've already seen
the -side
attribute for
pack()
. Another set of very useful
attributes include: -padx
,
-pady
, -ipadx
, and
-ipady
. These control how far a
widget is from the edges of its container and
how big it is itself (example).
- Use the
packForget()
method to remove
an item from the window, without deleting it.
Use ismapped()
to see if a widget
is currently displayed (example).
- Changing the text on a button or label is
straightforward using the
-textvariable
attribute. It's a
little trickier with Entry
or
Scrolled/Text
. In these cases, you
need to use the get()
or
delete()
methods which take special
indices to refer to particular places in the
text, e.g. "1.0" or "0.0" for the beginning and
"end" for the end. For an Entry
,
get()
takes no arguments and the
initial index seems to be "0.0". For a
Text
, both methods take indices as
arguments, but the initial index seems to be
"1.0"! (example,
example).