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
"""
@@ -847,7 +847,7 @@ def tk_focusNext(self):
847
847
The focus order first goes to the next child, then to
848
848
the children of the child recursively and then to the
849
849
next sibling which is higher in the stacking order. A
850
- widget is omitted if it has the takefocus resource set
850
+ widget is omitted if it has the takefocus option set
851
851
to 0."""
852
852
name = self .tk .call ('tk_focusNext' , self ._w )
853
853
if not name : return None
@@ -1827,18 +1827,24 @@ def _configure(self, cmd, cnf, kw):
1827
1827
# These used to be defined in Widget:
1828
1828
1829
1829
def configure (self , cnf = None , ** kw ):
1830
- """Configure resources of a widget.
1830
+ """Query or modify the configuration options of the widget.
1831
1831
1832
- The values for resources are specified as keyword
1833
- arguments. To get an overview about
1834
- the allowed keyword arguments call the method keys.
1832
+ If no arguments are specified, return a dictionary describing
1833
+ all of the available options for the widget.
1834
+
1835
+ If an option name is specified, then return a tuple describing
1836
+ the one named option.
1837
+
1838
+ If one or more keyword arguments are specified or a dictionary
1839
+ is specified, then modify the widget option(s) to have the given
1840
+ value(s).
1835
1841
"""
1836
1842
return self ._configure ('configure' , cnf , kw )
1837
1843
1838
1844
config = configure
1839
1845
1840
1846
def cget (self , key ):
1841
- """Return the resource value for a KEY given as string ."""
1847
+ """Return the current value of the configuration option ."""
1842
1848
return self .tk .call (self ._w , 'cget' , '-' + key )
1843
1849
1844
1850
__getitem__ = cget
@@ -1847,7 +1853,7 @@ def __setitem__(self, key, value):
1847
1853
self .configure ({key : value })
1848
1854
1849
1855
def keys (self ):
1850
- """Return a list of all resource names of this widget."""
1856
+ """Return a list of all option names of this widget."""
1851
1857
splitlist = self .tk .splitlist
1852
1858
return [splitlist (x )[0 ][1 :] for x in
1853
1859
splitlist (self .tk .call (self ._w , 'configure' ))]
@@ -1966,7 +1972,7 @@ def _grid_configure(self, command, index, cnf, kw):
1966
1972
def grid_columnconfigure (self , index , cnf = {}, ** kw ):
1967
1973
"""Configure column INDEX of a grid.
1968
1974
1969
- Valid resources are minsize (minimum size of the column),
1975
+ Valid options are minsize (minimum size of the column),
1970
1976
weight (how much does additional space propagate to this column)
1971
1977
and pad (how much space to let additionally)."""
1972
1978
return self ._grid_configure ('columnconfigure' , index , cnf , kw )
@@ -1997,7 +2003,7 @@ def grid_propagate(self, flag=_noarg_):
1997
2003
def grid_rowconfigure (self , index , cnf = {}, ** kw ):
1998
2004
"""Configure row INDEX of a grid.
1999
2005
2000
- Valid resources are minsize (minimum size of the row),
2006
+ Valid options are minsize (minimum size of the row),
2001
2007
weight (how much does additional space propagate to this row)
2002
2008
and pad (how much space to let additionally)."""
2003
2009
return self ._grid_configure ('rowconfigure' , index , cnf , kw )
@@ -2817,7 +2823,7 @@ class Toplevel(BaseWidget, Wm):
2817
2823
def __init__ (self , master = None , cnf = {}, ** kw ):
2818
2824
"""Construct a toplevel widget with the parent MASTER.
2819
2825
2820
- Valid resource names: background, bd, bg, borderwidth, class,
2826
+ Valid option names: background, bd, bg, borderwidth, class,
2821
2827
colormap, container, cursor, height, highlightbackground,
2822
2828
highlightcolor, highlightthickness, menu, relief, screen, takefocus,
2823
2829
use, visual, width."""
@@ -2894,7 +2900,7 @@ class Canvas(Widget, XView, YView):
2894
2900
def __init__ (self , master = None , cnf = {}, ** kw ):
2895
2901
"""Construct a canvas widget with the parent MASTER.
2896
2902
2897
- Valid resource names: background, bd, bg, borderwidth, closeenough,
2903
+ Valid option names: background, bd, bg, borderwidth, closeenough,
2898
2904
confine, cursor, height, highlightbackground, highlightcolor,
2899
2905
highlightthickness, insertbackground, insertborderwidth,
2900
2906
insertofftime, insertontime, insertwidth, offset, relief,
@@ -3103,16 +3109,14 @@ def insert(self, *args):
3103
3109
self .tk .call ((self ._w , 'insert' ) + args )
3104
3110
3105
3111
def itemcget (self , tagOrId , option ):
3106
- """Return the resource value for an OPTION for item TAGORID."""
3112
+ """Return the value of OPTION for item TAGORID."""
3107
3113
return self .tk .call (
3108
3114
(self ._w , 'itemcget' ) + (tagOrId , '-' + option ))
3109
3115
3110
3116
def itemconfigure (self , tagOrId , cnf = None , ** kw ):
3111
- """Configure resources of an item TAGORID.
3117
+ """Query or modify the configuration options of an item TAGORID.
3112
3118
3113
- The values for resources are specified as keyword
3114
- arguments. To get an overview about
3115
- the allowed keyword arguments call the method without arguments.
3119
+ Similar to configure() except that it applies to the specified item.
3116
3120
"""
3117
3121
return self ._configure (('itemconfigure' , tagOrId ), cnf , kw )
3118
3122
@@ -3204,7 +3208,7 @@ class Checkbutton(Widget):
3204
3208
def __init__ (self , master = None , cnf = {}, ** kw ):
3205
3209
"""Construct a checkbutton widget with the parent MASTER.
3206
3210
3207
- Valid resource names: activebackground, activeforeground, anchor,
3211
+ Valid option names: activebackground, activeforeground, anchor,
3208
3212
background, bd, bg, bitmap, borderwidth, command, cursor,
3209
3213
disabledforeground, fg, font, foreground, height,
3210
3214
highlightbackground, highlightcolor, highlightthickness, image,
@@ -3235,7 +3239,7 @@ def flash(self):
3235
3239
self .tk .call (self ._w , 'flash' )
3236
3240
3237
3241
def invoke (self ):
3238
- """Toggle the button and invoke a command if given as resource ."""
3242
+ """Toggle the button and invoke a command if given as option ."""
3239
3243
return self .tk .call (self ._w , 'invoke' )
3240
3244
3241
3245
def select (self ):
@@ -3253,7 +3257,7 @@ class Entry(Widget, XView):
3253
3257
def __init__ (self , master = None , cnf = {}, ** kw ):
3254
3258
"""Construct an entry widget with the parent MASTER.
3255
3259
3256
- Valid resource names: background, bd, bg, borderwidth, cursor,
3260
+ Valid option names: background, bd, bg, borderwidth, cursor,
3257
3261
exportselection, fg, font, foreground, highlightbackground,
3258
3262
highlightcolor, highlightthickness, insertbackground,
3259
3263
insertborderwidth, insertofftime, insertontime, insertwidth,
@@ -3339,7 +3343,7 @@ class Frame(Widget):
3339
3343
def __init__ (self , master = None , cnf = {}, ** kw ):
3340
3344
"""Construct a frame widget with the parent MASTER.
3341
3345
3342
- Valid resource names: background, bd, bg, borderwidth, class,
3346
+ Valid option names: background, bd, bg, borderwidth, class,
3343
3347
colormap, container, cursor, height, highlightbackground,
3344
3348
highlightcolor, highlightthickness, relief, takefocus, visual, width."""
3345
3349
cnf = _cnfmerge ((cnf , kw ))
@@ -3383,7 +3387,7 @@ class Listbox(Widget, XView, YView):
3383
3387
def __init__ (self , master = None , cnf = {}, ** kw ):
3384
3388
"""Construct a listbox widget with the parent MASTER.
3385
3389
3386
- Valid resource names: background, bd, bg, borderwidth, cursor,
3390
+ Valid option names: background, bd, bg, borderwidth, cursor,
3387
3391
exportselection, fg, font, foreground, height, highlightbackground,
3388
3392
highlightcolor, highlightthickness, relief, selectbackground,
3389
3393
selectborderwidth, selectforeground, selectmode, setgrid, takefocus,
@@ -3476,18 +3480,15 @@ def size(self):
3476
3480
return self .tk .getint (self .tk .call (self ._w , 'size' ))
3477
3481
3478
3482
def itemcget (self , index , option ):
3479
- """Return the resource value for an ITEM and an OPTION ."""
3483
+ """Return the value of OPTION for item at INDEX ."""
3480
3484
return self .tk .call (
3481
3485
(self ._w , 'itemcget' ) + (index , '-' + option ))
3482
3486
3483
3487
def itemconfigure (self , index , cnf = None , ** kw ):
3484
- """Configure resources of an ITEM .
3488
+ """Query or modify the configuration options of an item at INDEX .
3485
3489
3486
- The values for resources are specified as keyword arguments.
3487
- To get an overview about the allowed keyword arguments
3488
- call the method without arguments.
3489
- Valid resource names: background, bg, foreground, fg,
3490
- selectbackground, selectforeground."""
3490
+ Similar to configure() except that it applies to the specified item.
3491
+ """
3491
3492
return self ._configure (('itemconfigure' , index ), cnf , kw )
3492
3493
3493
3494
itemconfig = itemconfigure
@@ -3499,7 +3500,7 @@ class Menu(Widget):
3499
3500
def __init__ (self , master = None , cnf = {}, ** kw ):
3500
3501
"""Construct menu widget with the parent MASTER.
3501
3502
3502
- Valid resource names: activebackground, activeborderwidth,
3503
+ Valid option names: activebackground, activeborderwidth,
3503
3504
activeforeground, background, bd, bg, borderwidth, cursor,
3504
3505
disabledforeground, fg, font, foreground, postcommand, relief,
3505
3506
selectcolor, takefocus, tearoff, tearoffcommand, title, type."""
@@ -3580,11 +3581,15 @@ def delete(self, index1, index2=None):
3580
3581
self .tk .call (self ._w , 'delete' , index1 , index2 )
3581
3582
3582
3583
def entrycget (self , index , option ):
3583
- """Return the resource value of a menu item for OPTION at INDEX."""
3584
+ """Return the value of OPTION for a menu item at INDEX."""
3584
3585
return self .tk .call (self ._w , 'entrycget' , index , '-' + option )
3585
3586
3586
3587
def entryconfigure (self , index , cnf = None , ** kw ):
3587
- """Configure a menu item at INDEX."""
3588
+ """Query or modify the configuration options of a menu item at INDEX.
3589
+
3590
+ Similar to configure() except that it applies to the specified
3591
+ menu item.
3592
+ """
3588
3593
return self ._configure (('entryconfigure' , index ), cnf , kw )
3589
3594
3590
3595
entryconfig = entryconfigure
@@ -3642,7 +3647,7 @@ class Radiobutton(Widget):
3642
3647
def __init__ (self , master = None , cnf = {}, ** kw ):
3643
3648
"""Construct a radiobutton widget with the parent MASTER.
3644
3649
3645
- Valid resource names: activebackground, activeforeground, anchor,
3650
+ Valid option names: activebackground, activeforeground, anchor,
3646
3651
background, bd, bg, bitmap, borderwidth, command, cursor,
3647
3652
disabledforeground, fg, font, foreground, height,
3648
3653
highlightbackground, highlightcolor, highlightthickness, image,
@@ -3661,7 +3666,7 @@ def flash(self):
3661
3666
self .tk .call (self ._w , 'flash' )
3662
3667
3663
3668
def invoke (self ):
3664
- """Toggle the button and invoke a command if given as resource ."""
3669
+ """Toggle the button and invoke a command if given as option ."""
3665
3670
return self .tk .call (self ._w , 'invoke' )
3666
3671
3667
3672
def select (self ):
@@ -3675,7 +3680,7 @@ class Scale(Widget):
3675
3680
def __init__ (self , master = None , cnf = {}, ** kw ):
3676
3681
"""Construct a scale widget with the parent MASTER.
3677
3682
3678
- Valid resource names: activebackground, background, bigincrement, bd,
3683
+ Valid option names: activebackground, background, bigincrement, bd,
3679
3684
bg, borderwidth, command, cursor, digits, fg, font, foreground, from,
3680
3685
highlightbackground, highlightcolor, highlightthickness, label,
3681
3686
length, orient, relief, repeatdelay, repeatinterval, resolution,
@@ -3714,7 +3719,7 @@ class Scrollbar(Widget):
3714
3719
def __init__ (self , master = None , cnf = {}, ** kw ):
3715
3720
"""Construct a scrollbar widget with the parent MASTER.
3716
3721
3717
- Valid resource names: activebackground, activerelief,
3722
+ Valid option names: activebackground, activerelief,
3718
3723
background, bd, bg, borderwidth, command, cursor,
3719
3724
elementborderwidth, highlightbackground,
3720
3725
highlightcolor, highlightthickness, jump, orient,
@@ -3958,7 +3963,11 @@ def image_cget(self, index, option):
3958
3963
return self .tk .call (self ._w , "image" , "cget" , index , option )
3959
3964
3960
3965
def image_configure (self , index , cnf = None , ** kw ):
3961
- """Configure an embedded image at INDEX."""
3966
+ """Query or modify the configuration options of an embedded image at INDEX.
3967
+
3968
+ Similar to configure() except that it applies to the specified
3969
+ embedded image.
3970
+ """
3962
3971
return self ._configure (('image' , 'configure' , index ), cnf , kw )
3963
3972
3964
3973
def image_create (self , index , cnf = {}, ** kw ):
@@ -4096,7 +4105,10 @@ def tag_cget(self, tagName, option):
4096
4105
return self .tk .call (self ._w , 'tag' , 'cget' , tagName , option )
4097
4106
4098
4107
def tag_configure (self , tagName , cnf = None , ** kw ):
4099
- """Configure a tag TAGNAME."""
4108
+ """Query or modify the configuration options of a tag TAGNAME.
4109
+
4110
+ Similar to configure() except that it applies to the specified tag.
4111
+ """
4100
4112
return self ._configure (('tag' , 'configure' , tagName ), cnf , kw )
4101
4113
4102
4114
tag_config = tag_configure
@@ -4154,7 +4166,11 @@ def window_cget(self, index, option):
4154
4166
return self .tk .call (self ._w , 'window' , 'cget' , index , option )
4155
4167
4156
4168
def window_configure (self , index , cnf = None , ** kw ):
4157
- """Configure an embedded window at INDEX."""
4169
+ """Query or modify the configuration options of an embedded window at INDEX.
4170
+
4171
+ Similar to configure() except that it applies to the specified
4172
+ embedded window.
4173
+ """
4158
4174
return self ._configure (('window' , 'configure' , index ), cnf , kw )
4159
4175
4160
4176
window_config = window_configure
@@ -4194,7 +4210,7 @@ class OptionMenu(Menubutton):
4194
4210
4195
4211
def __init__ (self , master , variable , value , * values , ** kwargs ):
4196
4212
"""Construct an optionmenu widget with the parent MASTER, with
4197
- the resource textvariable set to VARIABLE, the initially selected
4213
+ the option textvariable set to VARIABLE, the initially selected
4198
4214
value VALUE, the other menu values VALUES and an additional
4199
4215
keyword argument command."""
4200
4216
kw = {"borderwidth" : 2 , "textvariable" : variable ,
@@ -4296,7 +4312,7 @@ class PhotoImage(Image):
4296
4312
def __init__ (self , name = None , cnf = {}, master = None , ** kw ):
4297
4313
"""Create an image with NAME.
4298
4314
4299
- Valid resource names: data, format, file, gamma, height, palette,
4315
+ Valid option names: data, format, file, gamma, height, palette,
4300
4316
width."""
4301
4317
Image .__init__ (self , 'photo' , name , cnf , master , ** kw )
4302
4318
@@ -4559,7 +4575,7 @@ class BitmapImage(Image):
4559
4575
def __init__ (self , name = None , cnf = {}, master = None , ** kw ):
4560
4576
"""Create a bitmap with NAME.
4561
4577
4562
- Valid resource names: background, data, file, foreground, maskdata, maskfile."""
4578
+ Valid option names: background, data, file, foreground, maskdata, maskfile."""
4563
4579
Image .__init__ (self , 'bitmap' , name , cnf , master , ** kw )
4564
4580
4565
4581
@@ -4877,26 +4893,17 @@ def sash_place(self, index, x, y):
4877
4893
return self .sash ("place" , index , x , y )
4878
4894
4879
4895
def panecget (self , child , option ):
4880
- """Query a management option for window.
4881
-
4882
- Option may be any value allowed by the paneconfigure subcommand
4883
- """
4896
+ """Return the value of option for a child window."""
4884
4897
return self .tk .call (
4885
4898
(self ._w , 'panecget' ) + (child , '-' + option ))
4886
4899
4887
4900
def paneconfigure (self , tagOrId , cnf = None , ** kw ):
4888
- """Query or modify the management options for window.
4889
-
4890
- If no option is specified, returns a list describing all
4891
- of the available options for pathName. If option is
4892
- specified with no value, then the command returns a list
4893
- describing the one named option (this list will be identical
4894
- to the corresponding sublist of the value returned if no
4895
- option is specified). If one or more option-value pairs are
4896
- specified, then the command modifies the given widget
4897
- option(s) to have the given value(s); in this case the
4898
- command returns an empty string. The following options
4899
- are supported:
4901
+ """Query or modify the configuration options for a child window.
4902
+
4903
+ Similar to configure() except that it applies to the specified
4904
+ window.
4905
+
4906
+ The following options are supported:
4900
4907
4901
4908
after window
4902
4909
Insert the window after the window specified. window
0 commit comments