7
7
LabelFrame and PanedWindow.
8
8
9
9
Properties of the widgets are specified with keyword arguments.
10
- Keyword arguments have the same name as the corresponding resource
10
+ Keyword arguments have the same name as the corresponding options
11
11
under Tk.
12
12
13
13
Widgets are positioned with one of the geometry managers Place, Pack
14
14
or Grid. These managers can be called with methods place, pack, grid
15
15
available in every Widget.
16
16
17
- Actions are bound to events by resources (e.g. keyword argument
18
- command ) or with the method bind.
17
+ Actions are bound to events by options (e.g. the command
18
+ keyword argument ) or with the bind() method .
19
19
20
20
Example (Hello, World):
21
21
import tkinter
22
22
from tkinter.constants import *
23
23
tk = tkinter.Tk()
24
24
frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
25
- frame.pack(fill=BOTH,expand=1)
25
+ frame.pack(fill=BOTH, expand=1)
26
26
label = tkinter.Label(frame, text="Hello, World")
27
27
label.pack(fill=X, expand=1)
28
- button = tkinter.Button(frame,text="Exit",command=tk.destroy)
28
+ button = tkinter.Button(frame, text="Exit", command=tk.destroy)
29
29
button.pack(side=BOTTOM)
30
30
tk.mainloop()
31
31
"""
@@ -833,7 +833,7 @@ def tk_focusNext(self):
833
833
The focus order first goes to the next child, then to
834
834
the children of the child recursively and then to the
835
835
next sibling which is higher in the stacking order. A
836
- widget is omitted if it has the takefocus resource set
836
+ widget is omitted if it has the takefocus option set
837
837
to 0."""
838
838
name = self .tk .call ('tk_focusNext' , self ._w )
839
839
if not name : return None
@@ -1813,18 +1813,24 @@ def _configure(self, cmd, cnf, kw):
1813
1813
# These used to be defined in Widget:
1814
1814
1815
1815
def configure (self , cnf = None , ** kw ):
1816
- """Configure resources of a widget.
1816
+ """Query or modify the configuration options of the widget.
1817
1817
1818
- The values for resources are specified as keyword
1819
- arguments. To get an overview about
1820
- the allowed keyword arguments call the method keys.
1818
+ If no arguments are specified, return a dictionary describing
1819
+ all of the available options for the widget.
1820
+
1821
+ If an option name is specified, then return a tuple describing
1822
+ the one named option.
1823
+
1824
+ If one or more keyword arguments are specified or a dictionary
1825
+ is specified, then modify the widget option(s) to have the given
1826
+ value(s).
1821
1827
"""
1822
1828
return self ._configure ('configure' , cnf , kw )
1823
1829
1824
1830
config = configure
1825
1831
1826
1832
def cget (self , key ):
1827
- """Return the resource value for a KEY given as string ."""
1833
+ """Return the current value of the configuration option ."""
1828
1834
return self .tk .call (self ._w , 'cget' , '-' + key )
1829
1835
1830
1836
__getitem__ = cget
@@ -1833,7 +1839,7 @@ def __setitem__(self, key, value):
1833
1839
self .configure ({key : value })
1834
1840
1835
1841
def keys (self ):
1836
- """Return a list of all resource names of this widget."""
1842
+ """Return a list of all option names of this widget."""
1837
1843
splitlist = self .tk .splitlist
1838
1844
return [splitlist (x )[0 ][1 :] for x in
1839
1845
splitlist (self .tk .call (self ._w , 'configure' ))]
@@ -1952,7 +1958,7 @@ def _grid_configure(self, command, index, cnf, kw):
1952
1958
def grid_columnconfigure (self , index , cnf = {}, ** kw ):
1953
1959
"""Configure column INDEX of a grid.
1954
1960
1955
- Valid resources are minsize (minimum size of the column),
1961
+ Valid options are minsize (minimum size of the column),
1956
1962
weight (how much does additional space propagate to this column)
1957
1963
and pad (how much space to let additionally)."""
1958
1964
return self ._grid_configure ('columnconfigure' , index , cnf , kw )
@@ -1983,7 +1989,7 @@ def grid_propagate(self, flag=_noarg_):
1983
1989
def grid_rowconfigure (self , index , cnf = {}, ** kw ):
1984
1990
"""Configure row INDEX of a grid.
1985
1991
1986
- Valid resources are minsize (minimum size of the row),
1992
+ Valid options are minsize (minimum size of the row),
1987
1993
weight (how much does additional space propagate to this row)
1988
1994
and pad (how much space to let additionally)."""
1989
1995
return self ._grid_configure ('rowconfigure' , index , cnf , kw )
@@ -2803,7 +2809,7 @@ class Toplevel(BaseWidget, Wm):
2803
2809
def __init__ (self , master = None , cnf = {}, ** kw ):
2804
2810
"""Construct a toplevel widget with the parent MASTER.
2805
2811
2806
- Valid resource names: background, bd, bg, borderwidth, class,
2812
+ Valid option names: background, bd, bg, borderwidth, class,
2807
2813
colormap, container, cursor, height, highlightbackground,
2808
2814
highlightcolor, highlightthickness, menu, relief, screen, takefocus,
2809
2815
use, visual, width."""
@@ -2880,7 +2886,7 @@ class Canvas(Widget, XView, YView):
2880
2886
def __init__ (self , master = None , cnf = {}, ** kw ):
2881
2887
"""Construct a canvas widget with the parent MASTER.
2882
2888
2883
- Valid resource names: background, bd, bg, borderwidth, closeenough,
2889
+ Valid option names: background, bd, bg, borderwidth, closeenough,
2884
2890
confine, cursor, height, highlightbackground, highlightcolor,
2885
2891
highlightthickness, insertbackground, insertborderwidth,
2886
2892
insertofftime, insertontime, insertwidth, offset, relief,
@@ -3089,16 +3095,14 @@ def insert(self, *args):
3089
3095
self .tk .call ((self ._w , 'insert' ) + args )
3090
3096
3091
3097
def itemcget (self , tagOrId , option ):
3092
- """Return the resource value for an OPTION for item TAGORID."""
3098
+ """Return the value of OPTION for item TAGORID."""
3093
3099
return self .tk .call (
3094
3100
(self ._w , 'itemcget' ) + (tagOrId , '-' + option ))
3095
3101
3096
3102
def itemconfigure (self , tagOrId , cnf = None , ** kw ):
3097
- """Configure resources of an item TAGORID.
3103
+ """Query or modify the configuration options of an item TAGORID.
3098
3104
3099
- The values for resources are specified as keyword
3100
- arguments. To get an overview about
3101
- the allowed keyword arguments call the method without arguments.
3105
+ Similar to configure() except that it applies to the specified item.
3102
3106
"""
3103
3107
return self ._configure (('itemconfigure' , tagOrId ), cnf , kw )
3104
3108
@@ -3190,7 +3194,7 @@ class Checkbutton(Widget):
3190
3194
def __init__ (self , master = None , cnf = {}, ** kw ):
3191
3195
"""Construct a checkbutton widget with the parent MASTER.
3192
3196
3193
- Valid resource names: activebackground, activeforeground, anchor,
3197
+ Valid option names: activebackground, activeforeground, anchor,
3194
3198
background, bd, bg, bitmap, borderwidth, command, cursor,
3195
3199
disabledforeground, fg, font, foreground, height,
3196
3200
highlightbackground, highlightcolor, highlightthickness, image,
@@ -3221,7 +3225,7 @@ def flash(self):
3221
3225
self .tk .call (self ._w , 'flash' )
3222
3226
3223
3227
def invoke (self ):
3224
- """Toggle the button and invoke a command if given as resource ."""
3228
+ """Toggle the button and invoke a command if given as option ."""
3225
3229
return self .tk .call (self ._w , 'invoke' )
3226
3230
3227
3231
def select (self ):
@@ -3239,7 +3243,7 @@ class Entry(Widget, XView):
3239
3243
def __init__ (self , master = None , cnf = {}, ** kw ):
3240
3244
"""Construct an entry widget with the parent MASTER.
3241
3245
3242
- Valid resource names: background, bd, bg, borderwidth, cursor,
3246
+ Valid option names: background, bd, bg, borderwidth, cursor,
3243
3247
exportselection, fg, font, foreground, highlightbackground,
3244
3248
highlightcolor, highlightthickness, insertbackground,
3245
3249
insertborderwidth, insertofftime, insertontime, insertwidth,
@@ -3325,7 +3329,7 @@ class Frame(Widget):
3325
3329
def __init__ (self , master = None , cnf = {}, ** kw ):
3326
3330
"""Construct a frame widget with the parent MASTER.
3327
3331
3328
- Valid resource names: background, bd, bg, borderwidth, class,
3332
+ Valid option names: background, bd, bg, borderwidth, class,
3329
3333
colormap, container, cursor, height, highlightbackground,
3330
3334
highlightcolor, highlightthickness, relief, takefocus, visual, width."""
3331
3335
cnf = _cnfmerge ((cnf , kw ))
@@ -3369,7 +3373,7 @@ class Listbox(Widget, XView, YView):
3369
3373
def __init__ (self , master = None , cnf = {}, ** kw ):
3370
3374
"""Construct a listbox widget with the parent MASTER.
3371
3375
3372
- Valid resource names: background, bd, bg, borderwidth, cursor,
3376
+ Valid option names: background, bd, bg, borderwidth, cursor,
3373
3377
exportselection, fg, font, foreground, height, highlightbackground,
3374
3378
highlightcolor, highlightthickness, relief, selectbackground,
3375
3379
selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
@@ -3462,18 +3466,15 @@ def size(self):
3462
3466
return self .tk .getint (self .tk .call (self ._w , 'size' ))
3463
3467
3464
3468
def itemcget (self , index , option ):
3465
- """Return the resource value for an ITEM and an OPTION ."""
3469
+ """Return the value of OPTION for item at INDEX ."""
3466
3470
return self .tk .call (
3467
3471
(self ._w , 'itemcget' ) + (index , '-' + option ))
3468
3472
3469
3473
def itemconfigure (self , index , cnf = None , ** kw ):
3470
- """Configure resources of an ITEM .
3474
+ """Query or modify the configuration options of an item at INDEX .
3471
3475
3472
- The values for resources are specified as keyword arguments.
3473
- To get an overview about the allowed keyword arguments
3474
- call the method without arguments.
3475
- Valid resource names: background, bg, foreground, fg,
3476
- selectbackground, selectforeground."""
3476
+ Similar to configure() except that it applies to the specified item.
3477
+ """
3477
3478
return self ._configure (('itemconfigure' , index ), cnf , kw )
3478
3479
3479
3480
itemconfig = itemconfigure
@@ -3485,7 +3486,7 @@ class Menu(Widget):
3485
3486
def __init__ (self , master = None , cnf = {}, ** kw ):
3486
3487
"""Construct menu widget with the parent MASTER.
3487
3488
3488
- Valid resource names: activebackground, activeborderwidth,
3489
+ Valid option names: activebackground, activeborderwidth,
3489
3490
activeforeground, background, bd, bg, borderwidth, cursor,
3490
3491
disabledforeground, fg, font, foreground, postcommand, relief,
3491
3492
selectcolor, takefocus, tearoff, tearoffcommand, title, type."""
@@ -3566,11 +3567,15 @@ def delete(self, index1, index2=None):
3566
3567
self .tk .call (self ._w , 'delete' , index1 , index2 )
3567
3568
3568
3569
def entrycget (self , index , option ):
3569
- """Return the resource value of a menu item for OPTION at INDEX."""
3570
+ """Return the value of OPTION for a menu item at INDEX."""
3570
3571
return self .tk .call (self ._w , 'entrycget' , index , '-' + option )
3571
3572
3572
3573
def entryconfigure (self , index , cnf = None , ** kw ):
3573
- """Configure a menu item at INDEX."""
3574
+ """Query or modify the configuration options of a menu item at INDEX.
3575
+
3576
+ Similar to configure() except that it applies to the specified
3577
+ menu item.
3578
+ """
3574
3579
return self ._configure (('entryconfigure' , index ), cnf , kw )
3575
3580
3576
3581
entryconfig = entryconfigure
@@ -3628,7 +3633,7 @@ class Radiobutton(Widget):
3628
3633
def __init__ (self , master = None , cnf = {}, ** kw ):
3629
3634
"""Construct a radiobutton widget with the parent MASTER.
3630
3635
3631
- Valid resource names: activebackground, activeforeground, anchor,
3636
+ Valid option names: activebackground, activeforeground, anchor,
3632
3637
background, bd, bg, bitmap, borderwidth, command, cursor,
3633
3638
disabledforeground, fg, font, foreground, height,
3634
3639
highlightbackground, highlightcolor, highlightthickness, image,
@@ -3647,7 +3652,7 @@ def flash(self):
3647
3652
self .tk .call (self ._w , 'flash' )
3648
3653
3649
3654
def invoke (self ):
3650
- """Toggle the button and invoke a command if given as resource ."""
3655
+ """Toggle the button and invoke a command if given as option ."""
3651
3656
return self .tk .call (self ._w , 'invoke' )
3652
3657
3653
3658
def select (self ):
@@ -3661,7 +3666,7 @@ class Scale(Widget):
3661
3666
def __init__ (self , master = None , cnf = {}, ** kw ):
3662
3667
"""Construct a scale widget with the parent MASTER.
3663
3668
3664
- Valid resource names: activebackground, background, bigincrement, bd,
3669
+ Valid option names: activebackground, background, bigincrement, bd,
3665
3670
bg, borderwidth, command, cursor, digits, fg, font, foreground, from,
3666
3671
highlightbackground, highlightcolor, highlightthickness, label,
3667
3672
length, orient, relief, repeatdelay, repeatinterval, resolution,
@@ -3700,7 +3705,7 @@ class Scrollbar(Widget):
3700
3705
def __init__ (self , master = None , cnf = {}, ** kw ):
3701
3706
"""Construct a scrollbar widget with the parent MASTER.
3702
3707
3703
- Valid resource names: activebackground, activerelief,
3708
+ Valid option names: activebackground, activerelief,
3704
3709
background, bd, bg, borderwidth, command, cursor,
3705
3710
elementborderwidth, highlightbackground,
3706
3711
highlightcolor, highlightthickness, jump, orient,
@@ -3944,7 +3949,11 @@ def image_cget(self, index, option):
3944
3949
return self .tk .call (self ._w , "image" , "cget" , index , option )
3945
3950
3946
3951
def image_configure (self , index , cnf = None , ** kw ):
3947
- """Configure an embedded image at INDEX."""
3952
+ """Query or modify the configuration options of an embedded image at INDEX.
3953
+
3954
+ Similar to configure() except that it applies to the specified
3955
+ embedded image.
3956
+ """
3948
3957
return self ._configure (('image' , 'configure' , index ), cnf , kw )
3949
3958
3950
3959
def image_create (self , index , cnf = {}, ** kw ):
@@ -4082,7 +4091,10 @@ def tag_cget(self, tagName, option):
4082
4091
return self .tk .call (self ._w , 'tag' , 'cget' , tagName , option )
4083
4092
4084
4093
def tag_configure (self , tagName , cnf = None , ** kw ):
4085
- """Configure a tag TAGNAME."""
4094
+ """Query or modify the configuration options of a tag TAGNAME.
4095
+
4096
+ Similar to configure() except that it applies to the specified tag.
4097
+ """
4086
4098
return self ._configure (('tag' , 'configure' , tagName ), cnf , kw )
4087
4099
4088
4100
tag_config = tag_configure
@@ -4140,7 +4152,11 @@ def window_cget(self, index, option):
4140
4152
return self .tk .call (self ._w , 'window' , 'cget' , index , option )
4141
4153
4142
4154
def window_configure (self , index , cnf = None , ** kw ):
4143
- """Configure an embedded window at INDEX."""
4155
+ """Query or modify the configuration options of an embedded window at INDEX.
4156
+
4157
+ Similar to configure() except that it applies to the specified
4158
+ embedded window.
4159
+ """
4144
4160
return self ._configure (('window' , 'configure' , index ), cnf , kw )
4145
4161
4146
4162
window_config = window_configure
@@ -4180,7 +4196,7 @@ class OptionMenu(Menubutton):
4180
4196
4181
4197
def __init__ (self , master , variable , value , * values , ** kwargs ):
4182
4198
"""Construct an optionmenu widget with the parent MASTER, with
4183
- the resource textvariable set to VARIABLE, the initially selected
4199
+ the option textvariable set to VARIABLE, the initially selected
4184
4200
value VALUE, the other menu values VALUES and an additional
4185
4201
keyword argument command."""
4186
4202
kw = {"borderwidth" : 2 , "textvariable" : variable ,
@@ -4282,7 +4298,7 @@ class PhotoImage(Image):
4282
4298
def __init__ (self , name = None , cnf = {}, master = None , ** kw ):
4283
4299
"""Create an image with NAME.
4284
4300
4285
- Valid resource names: data, format, file, gamma, height, palette,
4301
+ Valid option names: data, format, file, gamma, height, palette,
4286
4302
width."""
4287
4303
Image .__init__ (self , 'photo' , name , cnf , master , ** kw )
4288
4304
@@ -4545,7 +4561,7 @@ class BitmapImage(Image):
4545
4561
def __init__ (self , name = None , cnf = {}, master = None , ** kw ):
4546
4562
"""Create a bitmap with NAME.
4547
4563
4548
- Valid resource names: background, data, file, foreground, maskdata, maskfile."""
4564
+ Valid option names: background, data, file, foreground, maskdata, maskfile."""
4549
4565
Image .__init__ (self , 'bitmap' , name , cnf , master , ** kw )
4550
4566
4551
4567
@@ -4863,26 +4879,17 @@ def sash_place(self, index, x, y):
4863
4879
return self .sash ("place" , index , x , y )
4864
4880
4865
4881
def panecget (self , child , option ):
4866
- """Query a management option for window.
4867
-
4868
- Option may be any value allowed by the paneconfigure subcommand
4869
- """
4882
+ """Return the value of option for a child window."""
4870
4883
return self .tk .call (
4871
4884
(self ._w , 'panecget' ) + (child , '-' + option ))
4872
4885
4873
4886
def paneconfigure (self , tagOrId , cnf = None , ** kw ):
4874
- """Query or modify the management options for window.
4875
-
4876
- If no option is specified, returns a list describing all
4877
- of the available options for pathName. If option is
4878
- specified with no value, then the command returns a list
4879
- describing the one named option (this list will be identical
4880
- to the corresponding sublist of the value returned if no
4881
- option is specified). If one or more option-value pairs are
4882
- specified, then the command modifies the given widget
4883
- option(s) to have the given value(s); in this case the
4884
- command returns an empty string. The following options
4885
- are supported:
4887
+ """Query or modify the configuration options for a child window.
4888
+
4889
+ Similar to configure() except that it applies to the specified
4890
+ window.
4891
+
4892
+ The following options are supported:
4886
4893
4887
4894
after window
4888
4895
Insert the window after the window specified. window
0 commit comments