Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6ce1315b
Commit
6ce1315b
authored
Oct 10, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #612602: Streamline configure methods.
parent
dbe3f762
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
79 deletions
+29
-79
Lib/lib-tk/Tkinter.py
Lib/lib-tk/Tkinter.py
+24
-79
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/lib-tk/Tkinter.py
View file @
6ce1315b
...
@@ -1067,15 +1067,8 @@ class Misc:
...
@@ -1067,15 +1067,8 @@ class Misc:
exc
,
val
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
exc
,
val
,
tb
=
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
root
=
self
.
_root
()
root
=
self
.
_root
()
root
.
report_callback_exception
(
exc
,
val
,
tb
)
root
.
report_callback_exception
(
exc
,
val
,
tb
)
# These used to be defined in Widget:
def
_configure
(
self
,
cmd
,
cnf
,
kw
):
def
configure
(
self
,
cnf
=
None
,
**
kw
):
"""Internal function."""
"""Configure resources of a widget.
The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.
"""
# XXX ought to generalize this so tag_config etc. can use it
if
kw
:
if
kw
:
cnf
=
_cnfmerge
((
cnf
,
kw
))
cnf
=
_cnfmerge
((
cnf
,
kw
))
elif
cnf
:
elif
cnf
:
...
@@ -1083,15 +1076,23 @@ class Misc:
...
@@ -1083,15 +1076,23 @@ class Misc:
if
cnf
is
None
:
if
cnf
is
None
:
cnf
=
{}
cnf
=
{}
for
x
in
self
.
tk
.
split
(
for
x
in
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'configure'
)):
self
.
tk
.
call
(
_flatten
((
self
.
_w
,
cmd
))
)):
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
cnf
return
cnf
if
type
(
cnf
)
is
StringType
:
if
type
(
cnf
)
is
StringType
:
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
x
=
self
.
tk
.
split
(
self
.
_w
,
'configure'
,
'-'
+
cnf
))
self
.
tk
.
call
(
_flatten
((
self
.
_w
,
cmd
,
'-'
+
cnf
))
))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
((
self
.
_w
,
'configure'
)
self
.
tk
.
call
(
_flatten
((
self
.
_w
,
cmd
))
+
self
.
_options
(
cnf
))
+
self
.
_options
(
cnf
))
# These used to be defined in Widget:
def
configure
(
self
,
cnf
=
None
,
**
kw
):
"""Configure resources of a widget.
The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.
"""
return
self
.
_configure
(
'configure'
,
cnf
,
kw
)
config
=
configure
config
=
configure
def
cget
(
self
,
key
):
def
cget
(
self
,
key
):
"""Return the resource value for a KEY given as string."""
"""Return the resource value for a KEY given as string."""
...
@@ -2043,19 +2044,7 @@ class Canvas(Widget):
...
@@ -2043,19 +2044,7 @@ class Canvas(Widget):
arguments. To get an overview about
arguments. To get an overview about
the allowed keyword arguments call the method without arguments.
the allowed keyword arguments call the method without arguments.
"""
"""
if
cnf
is
None
and
not
kw
:
return
self
.
_configure
((
'itemconfigure'
,
tagOrId
),
cnf
,
kw
)
cnf
=
{}
for
x
in
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'itemconfigure'
,
tagOrId
)):
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
cnf
if
type
(
cnf
)
==
StringType
and
not
kw
:
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'itemconfigure'
,
tagOrId
,
'-'
+
cnf
))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
((
self
.
_w
,
'itemconfigure'
,
tagOrId
)
+
self
.
_options
(
cnf
,
kw
))
itemconfig
=
itemconfigure
itemconfig
=
itemconfigure
# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
# lower, tkraise/lift hide Misc.lower, Misc.tkraise/lift,
# so the preferred name for them is tag_lower, tag_raise
# so the preferred name for them is tag_lower, tag_raise
...
@@ -2383,18 +2372,7 @@ class Listbox(Widget):
...
@@ -2383,18 +2372,7 @@ class Listbox(Widget):
call the method without arguments.
call the method without arguments.
Valid resource names: background, bg, foreground, fg,
Valid resource names: background, bg, foreground, fg,
selectbackground, selectforeground."""
selectbackground, selectforeground."""
if
cnf
is
None
and
not
kw
:
return
self
.
_configure
((
'itemconfigure'
,
index
),
cnf
,
kw
)
cnf
=
{}
for
x
in
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'itemconfigure'
,
index
)):
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
cnf
if
type
(
cnf
)
==
StringType
and
not
kw
:
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'itemconfigure'
,
index
,
'-'
+
cnf
))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
((
self
.
_w
,
'itemconfigure'
,
index
)
+
self
.
_options
(
cnf
,
kw
))
itemconfig
=
itemconfigure
itemconfig
=
itemconfigure
class
Menu
(
Widget
):
class
Menu
(
Widget
):
...
@@ -2481,18 +2459,7 @@ class Menu(Widget):
...
@@ -2481,18 +2459,7 @@ class Menu(Widget):
return
self
.
tk
.
call
(
self
.
_w
,
'entrycget'
,
index
,
'-'
+
option
)
return
self
.
tk
.
call
(
self
.
_w
,
'entrycget'
,
index
,
'-'
+
option
)
def
entryconfigure
(
self
,
index
,
cnf
=
None
,
**
kw
):
def
entryconfigure
(
self
,
index
,
cnf
=
None
,
**
kw
):
"""Configure a menu item at INDEX."""
"""Configure a menu item at INDEX."""
if
cnf
is
None
and
not
kw
:
return
self
.
_configure
((
'entryconfigure'
,
index
),
cnf
,
kw
)
cnf
=
{}
for
x
in
self
.
tk
.
split
(
self
.
tk
.
call
(
(
self
.
_w
,
'entryconfigure'
,
index
))):
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
cnf
if
type
(
cnf
)
==
StringType
and
not
kw
:
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
(
self
.
_w
,
'entryconfigure'
,
index
,
'-'
+
cnf
)))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
((
self
.
_w
,
'entryconfigure'
,
index
)
+
self
.
_options
(
cnf
,
kw
))
entryconfig
=
entryconfigure
entryconfig
=
entryconfigure
def
index
(
self
,
index
):
def
index
(
self
,
index
):
"""Return the index of a menu item identified by INDEX."""
"""Return the index of a menu item identified by INDEX."""
...
@@ -2719,18 +2686,9 @@ class Text(Widget):
...
@@ -2719,18 +2686,9 @@ class Text(Widget):
if
option
[
-
1
:]
==
"_"
:
if
option
[
-
1
:]
==
"_"
:
option
=
option
[:
-
1
]
option
=
option
[:
-
1
]
return
self
.
tk
.
call
(
self
.
_w
,
"image"
,
"cget"
,
index
,
option
)
return
self
.
tk
.
call
(
self
.
_w
,
"image"
,
"cget"
,
index
,
option
)
def
image_configure
(
self
,
index
,
cnf
=
{}
,
**
kw
):
def
image_configure
(
self
,
index
,
cnf
=
None
,
**
kw
):
"""Configure an embedded image at INDEX."""
"""Configure an embedded image at INDEX."""
if
not
cnf
and
not
kw
:
return
self
.
_configure
((
'image'
,
'configure'
,
index
),
cnf
,
kw
)
cnf
=
{}
for
x
in
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
"image"
,
"configure"
,
index
)):
cnf
[
x
[
0
][
1
:]]
=
(
x
[
0
][
1
:],)
+
x
[
1
:]
return
cnf
apply
(
self
.
tk
.
call
,
(
self
.
_w
,
"image"
,
"configure"
,
index
)
+
self
.
_options
(
cnf
,
kw
))
def
image_create
(
self
,
index
,
cnf
=
{},
**
kw
):
def
image_create
(
self
,
index
,
cnf
=
{},
**
kw
):
"""Create an embedded image at INDEX."""
"""Create an embedded image at INDEX."""
return
apply
(
self
.
tk
.
call
,
return
apply
(
self
.
tk
.
call
,
...
@@ -2821,15 +2779,9 @@ class Text(Widget):
...
@@ -2821,15 +2779,9 @@ class Text(Widget):
if
option
[
-
1
:]
==
'_'
:
if
option
[
-
1
:]
==
'_'
:
option
=
option
[:
-
1
]
option
=
option
[:
-
1
]
return
self
.
tk
.
call
(
self
.
_w
,
'tag'
,
'cget'
,
tagName
,
option
)
return
self
.
tk
.
call
(
self
.
_w
,
'tag'
,
'cget'
,
tagName
,
option
)
def
tag_configure
(
self
,
tagName
,
cnf
=
{}
,
**
kw
):
def
tag_configure
(
self
,
tagName
,
cnf
=
None
,
**
kw
):
"""Configure a tag TAGNAME."""
"""Configure a tag TAGNAME."""
if
type
(
cnf
)
==
StringType
:
return
self
.
_configure
((
'tag'
,
'configure'
,
tagName
),
cnf
,
kw
)
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'tag'
,
'configure'
,
tagName
,
'-'
+
cnf
))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
(
(
self
.
_w
,
'tag'
,
'configure'
,
tagName
)
+
self
.
_options
(
cnf
,
kw
))
tag_config
=
tag_configure
tag_config
=
tag_configure
def
tag_delete
(
self
,
*
tagNames
):
def
tag_delete
(
self
,
*
tagNames
):
"""Delete all tags in TAGNAMES."""
"""Delete all tags in TAGNAMES."""
...
@@ -2874,16 +2826,9 @@ class Text(Widget):
...
@@ -2874,16 +2826,9 @@ class Text(Widget):
if
option
[
-
1
:]
==
'_'
:
if
option
[
-
1
:]
==
'_'
:
option
=
option
[:
-
1
]
option
=
option
[:
-
1
]
return
self
.
tk
.
call
(
self
.
_w
,
'window'
,
'cget'
,
index
,
option
)
return
self
.
tk
.
call
(
self
.
_w
,
'window'
,
'cget'
,
index
,
option
)
def
window_configure
(
self
,
index
,
cnf
=
{}
,
**
kw
):
def
window_configure
(
self
,
index
,
cnf
=
None
,
**
kw
):
"""Configure an embedded window at INDEX."""
"""Configure an embedded window at INDEX."""
if
type
(
cnf
)
==
StringType
:
return
self
.
_configure
((
'window'
,
'configure'
,
index
),
cnf
,
kw
)
x
=
self
.
tk
.
split
(
self
.
tk
.
call
(
self
.
_w
,
'window'
,
'configure'
,
index
,
'-'
+
cnf
))
return
(
x
[
0
][
1
:],)
+
x
[
1
:]
self
.
tk
.
call
(
(
self
.
_w
,
'window'
,
'configure'
,
index
)
+
self
.
_options
(
cnf
,
kw
))
window_config
=
window_configure
window_config
=
window_configure
def
window_create
(
self
,
index
,
cnf
=
{},
**
kw
):
def
window_create
(
self
,
index
,
cnf
=
{},
**
kw
):
"""Create a window at INDEX."""
"""Create a window at INDEX."""
...
...
Misc/ACKS
View file @
6ce1315b
...
@@ -414,6 +414,7 @@ Edward K. Ream
...
@@ -414,6 +414,7 @@ Edward K. Ream
Marc Recht
Marc Recht
John Redford
John Redford
Terry Reedy
Terry Reedy
Steve Reeves
Ofir Reichenberg
Ofir Reichenberg
Sean Reifschneider
Sean Reifschneider
Michael P. Reilly
Michael P. Reilly
...
...
Misc/NEWS
View file @
6ce1315b
...
@@ -354,6 +354,10 @@ Extension modules
...
@@ -354,6 +354,10 @@ Extension modules
Library
Library
-------
-------
-
Various
configure
methods
of
Tkinter
have
been
stream
-
lined
,
so
that
tag_configure
,
image_configure
,
window_configure
now
return
a
dictionary
when
invoked
with
no
argument
.
-
Importing
the
readline
module
now
no
longer
has
the
side
effect
of
-
Importing
the
readline
module
now
no
longer
has
the
side
effect
of
calling
setlocale
(
LC_CTYPE
,
""
).
The
initial
"C"
locale
,
or
calling
setlocale
(
LC_CTYPE
,
""
).
The
initial
"C"
locale
,
or
whatever
locale
is
explicitly
set
by
the
user
,
is
preserved
.
If
you
whatever
locale
is
explicitly
set
by
the
user
,
is
preserved
.
If
you
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment