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
7c6c100b
Commit
7c6c100b
authored
Oct 23, 2000
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make reindent.py happy (convert everything to 4-space indents!).
parent
7f305658
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
246 additions
and
249 deletions
+246
-249
Lib/lib-tk/Canvas.py
Lib/lib-tk/Canvas.py
+158
-158
Lib/lib-tk/Dialog.py
Lib/lib-tk/Dialog.py
+34
-34
Lib/lib-tk/ScrolledText.py
Lib/lib-tk/ScrolledText.py
+22
-22
Lib/lib-tk/Tkdnd.py
Lib/lib-tk/Tkdnd.py
+15
-15
Lib/lib-tk/Tkinter.py
Lib/lib-tk/Tkinter.py
+0
-1
Lib/lib-tk/tkCommonDialog.py
Lib/lib-tk/tkCommonDialog.py
+0
-1
Lib/lib-tk/tkFont.py
Lib/lib-tk/tkFont.py
+9
-9
Lib/lib-tk/tkSimpleDialog.py
Lib/lib-tk/tkSimpleDialog.py
+6
-7
Lib/lib-tk/turtle.py
Lib/lib-tk/turtle.py
+2
-2
No files found.
Lib/lib-tk/Canvas.py
View file @
7c6c100b
...
@@ -7,182 +7,182 @@ from Tkinter import Canvas, _cnfmerge, _flatten
...
@@ -7,182 +7,182 @@ from Tkinter import Canvas, _cnfmerge, _flatten
class
CanvasItem
:
class
CanvasItem
:
def
__init__
(
self
,
canvas
,
itemType
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
itemType
,
*
args
,
**
kw
):
self
.
canvas
=
canvas
self
.
canvas
=
canvas
self
.
id
=
canvas
.
_create
(
itemType
,
args
,
kw
)
self
.
id
=
canvas
.
_create
(
itemType
,
args
,
kw
)
if
not
hasattr
(
canvas
,
'items'
):
if
not
hasattr
(
canvas
,
'items'
):
canvas
.
items
=
{}
canvas
.
items
=
{}
canvas
.
items
[
self
.
id
]
=
self
canvas
.
items
[
self
.
id
]
=
self
def
__str__
(
self
):
def
__str__
(
self
):
return
str
(
self
.
id
)
return
str
(
self
.
id
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<%s, id=%d>'
%
(
self
.
__class__
.
__name__
,
self
.
id
)
return
'<%s, id=%d>'
%
(
self
.
__class__
.
__name__
,
self
.
id
)
def
delete
(
self
):
def
delete
(
self
):
del
self
.
canvas
.
items
[
self
.
id
]
del
self
.
canvas
.
items
[
self
.
id
]
self
.
canvas
.
delete
(
self
.
id
)
self
.
canvas
.
delete
(
self
.
id
)
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
v
=
self
.
canvas
.
tk
.
split
(
self
.
canvas
.
tk
.
call
(
v
=
self
.
canvas
.
tk
.
split
(
self
.
canvas
.
tk
.
call
(
self
.
canvas
.
_w
,
'itemconfigure'
,
self
.
canvas
.
_w
,
'itemconfigure'
,
self
.
id
,
'-'
+
key
))
self
.
id
,
'-'
+
key
))
return
v
[
4
]
return
v
[
4
]
cget
=
__getitem__
cget
=
__getitem__
def
__setitem__
(
self
,
key
,
value
):
def
__setitem__
(
self
,
key
,
value
):
self
.
canvas
.
itemconfig
(
self
.
id
,
{
key
:
value
})
self
.
canvas
.
itemconfig
(
self
.
id
,
{
key
:
value
})
def
keys
(
self
):
def
keys
(
self
):
if
not
hasattr
(
self
,
'_keys'
):
if
not
hasattr
(
self
,
'_keys'
):
self
.
_keys
=
map
(
lambda
x
,
tk
=
self
.
canvas
.
tk
:
self
.
_keys
=
map
(
lambda
x
,
tk
=
self
.
canvas
.
tk
:
tk
.
splitlist
(
x
)[
0
][
1
:],
tk
.
splitlist
(
x
)[
0
][
1
:],
self
.
canvas
.
tk
.
splitlist
(
self
.
canvas
.
tk
.
splitlist
(
self
.
canvas
.
_do
(
self
.
canvas
.
_do
(
'itemconfigure'
,
'itemconfigure'
,
(
self
.
id
,))))
(
self
.
id
,))))
return
self
.
_keys
return
self
.
_keys
def
has_key
(
self
,
key
):
def
has_key
(
self
,
key
):
return
key
in
self
.
keys
()
return
key
in
self
.
keys
()
def
addtag
(
self
,
tag
,
option
=
'withtag'
):
def
addtag
(
self
,
tag
,
option
=
'withtag'
):
self
.
canvas
.
addtag
(
tag
,
option
,
self
.
id
)
self
.
canvas
.
addtag
(
tag
,
option
,
self
.
id
)
def
bbox
(
self
):
def
bbox
(
self
):
x1
,
y1
,
x2
,
y2
=
self
.
canvas
.
bbox
(
self
.
id
)
x1
,
y1
,
x2
,
y2
=
self
.
canvas
.
bbox
(
self
.
id
)
return
(
x1
,
y1
),
(
x2
,
y2
)
return
(
x1
,
y1
),
(
x2
,
y2
)
def
bind
(
self
,
sequence
=
None
,
command
=
None
,
add
=
None
):
def
bind
(
self
,
sequence
=
None
,
command
=
None
,
add
=
None
):
return
self
.
canvas
.
tag_bind
(
self
.
id
,
sequence
,
command
,
add
)
return
self
.
canvas
.
tag_bind
(
self
.
id
,
sequence
,
command
,
add
)
def
unbind
(
self
,
sequence
,
funcid
=
None
):
def
unbind
(
self
,
sequence
,
funcid
=
None
):
self
.
canvas
.
tag_unbind
(
self
.
id
,
sequence
,
funcid
)
self
.
canvas
.
tag_unbind
(
self
.
id
,
sequence
,
funcid
)
def
config
(
self
,
cnf
=
{},
**
kw
):
def
config
(
self
,
cnf
=
{},
**
kw
):
return
self
.
canvas
.
itemconfig
(
self
.
id
,
_cnfmerge
((
cnf
,
kw
)))
return
self
.
canvas
.
itemconfig
(
self
.
id
,
_cnfmerge
((
cnf
,
kw
)))
def
coords
(
self
,
pts
=
()):
def
coords
(
self
,
pts
=
()):
flat
=
()
flat
=
()
for
x
,
y
in
pts
:
flat
=
flat
+
(
x
,
y
)
for
x
,
y
in
pts
:
flat
=
flat
+
(
x
,
y
)
return
apply
(
self
.
canvas
.
coords
,
(
self
.
id
,)
+
flat
)
return
apply
(
self
.
canvas
.
coords
,
(
self
.
id
,)
+
flat
)
def
dchars
(
self
,
first
,
last
=
None
):
def
dchars
(
self
,
first
,
last
=
None
):
self
.
canvas
.
dchars
(
self
.
id
,
first
,
last
)
self
.
canvas
.
dchars
(
self
.
id
,
first
,
last
)
def
dtag
(
self
,
ttd
):
def
dtag
(
self
,
ttd
):
self
.
canvas
.
dtag
(
self
.
id
,
ttd
)
self
.
canvas
.
dtag
(
self
.
id
,
ttd
)
def
focus
(
self
):
def
focus
(
self
):
self
.
canvas
.
focus
(
self
.
id
)
self
.
canvas
.
focus
(
self
.
id
)
def
gettags
(
self
):
def
gettags
(
self
):
return
self
.
canvas
.
gettags
(
self
.
id
)
return
self
.
canvas
.
gettags
(
self
.
id
)
def
icursor
(
self
,
index
):
def
icursor
(
self
,
index
):
self
.
canvas
.
icursor
(
self
.
id
,
index
)
self
.
canvas
.
icursor
(
self
.
id
,
index
)
def
index
(
self
,
index
):
def
index
(
self
,
index
):
return
self
.
canvas
.
index
(
self
.
id
,
index
)
return
self
.
canvas
.
index
(
self
.
id
,
index
)
def
insert
(
self
,
beforethis
,
string
):
def
insert
(
self
,
beforethis
,
string
):
self
.
canvas
.
insert
(
self
.
id
,
beforethis
,
string
)
self
.
canvas
.
insert
(
self
.
id
,
beforethis
,
string
)
def
lower
(
self
,
belowthis
=
None
):
def
lower
(
self
,
belowthis
=
None
):
self
.
canvas
.
tag_lower
(
self
.
id
,
belowthis
)
self
.
canvas
.
tag_lower
(
self
.
id
,
belowthis
)
def
move
(
self
,
xamount
,
yamount
):
def
move
(
self
,
xamount
,
yamount
):
self
.
canvas
.
move
(
self
.
id
,
xamount
,
yamount
)
self
.
canvas
.
move
(
self
.
id
,
xamount
,
yamount
)
def
tkraise
(
self
,
abovethis
=
None
):
def
tkraise
(
self
,
abovethis
=
None
):
self
.
canvas
.
tag_raise
(
self
.
id
,
abovethis
)
self
.
canvas
.
tag_raise
(
self
.
id
,
abovethis
)
raise_
=
tkraise
# BW compat
raise_
=
tkraise
# BW compat
def
scale
(
self
,
xorigin
,
yorigin
,
xscale
,
yscale
):
def
scale
(
self
,
xorigin
,
yorigin
,
xscale
,
yscale
):
self
.
canvas
.
scale
(
self
.
id
,
xorigin
,
yorigin
,
xscale
,
yscale
)
self
.
canvas
.
scale
(
self
.
id
,
xorigin
,
yorigin
,
xscale
,
yscale
)
def
type
(
self
):
def
type
(
self
):
return
self
.
canvas
.
type
(
self
.
id
)
return
self
.
canvas
.
type
(
self
.
id
)
class
Arc
(
CanvasItem
):
class
Arc
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'arc'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'arc'
)
+
args
,
kw
)
class
Bitmap
(
CanvasItem
):
class
Bitmap
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'bitmap'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'bitmap'
)
+
args
,
kw
)
class
ImageItem
(
CanvasItem
):
class
ImageItem
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'image'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'image'
)
+
args
,
kw
)
class
Line
(
CanvasItem
):
class
Line
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'line'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'line'
)
+
args
,
kw
)
class
Oval
(
CanvasItem
):
class
Oval
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'oval'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'oval'
)
+
args
,
kw
)
class
Polygon
(
CanvasItem
):
class
Polygon
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'polygon'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'polygon'
)
+
args
,
kw
)
class
Rectangle
(
CanvasItem
):
class
Rectangle
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'rectangle'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'rectangle'
)
+
args
,
kw
)
# XXX "Text" is taken by the Text widget...
# XXX "Text" is taken by the Text widget...
class
CanvasText
(
CanvasItem
):
class
CanvasText
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'text'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'text'
)
+
args
,
kw
)
class
Window
(
CanvasItem
):
class
Window
(
CanvasItem
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
def
__init__
(
self
,
canvas
,
*
args
,
**
kw
):
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'window'
)
+
args
,
kw
)
apply
(
CanvasItem
.
__init__
,
(
self
,
canvas
,
'window'
)
+
args
,
kw
)
class
Group
:
class
Group
:
def
__init__
(
self
,
canvas
,
tag
=
None
):
def
__init__
(
self
,
canvas
,
tag
=
None
):
if
not
tag
:
if
not
tag
:
tag
=
'Group%d'
%
id
(
self
)
tag
=
'Group%d'
%
id
(
self
)
self
.
tag
=
self
.
id
=
tag
self
.
tag
=
self
.
id
=
tag
self
.
canvas
=
canvas
self
.
canvas
=
canvas
self
.
canvas
.
dtag
(
self
.
tag
)
self
.
canvas
.
dtag
(
self
.
tag
)
def
str
(
self
):
def
str
(
self
):
return
self
.
tag
return
self
.
tag
__str__
=
str
__str__
=
str
def
_do
(
self
,
cmd
,
*
args
):
def
_do
(
self
,
cmd
,
*
args
):
return
self
.
canvas
.
_do
(
cmd
,
(
self
.
tag
,)
+
_flatten
(
args
))
return
self
.
canvas
.
_do
(
cmd
,
(
self
.
tag
,)
+
_flatten
(
args
))
def
addtag_above
(
self
,
tagOrId
):
def
addtag_above
(
self
,
tagOrId
):
self
.
_do
(
'addtag'
,
'above'
,
tagOrId
)
self
.
_do
(
'addtag'
,
'above'
,
tagOrId
)
def
addtag_all
(
self
):
def
addtag_all
(
self
):
self
.
_do
(
'addtag'
,
'all'
)
self
.
_do
(
'addtag'
,
'all'
)
def
addtag_below
(
self
,
tagOrId
):
def
addtag_below
(
self
,
tagOrId
):
self
.
_do
(
'addtag'
,
'below'
,
tagOrId
)
self
.
_do
(
'addtag'
,
'below'
,
tagOrId
)
def
addtag_closest
(
self
,
x
,
y
,
halo
=
None
,
start
=
None
):
def
addtag_closest
(
self
,
x
,
y
,
halo
=
None
,
start
=
None
):
self
.
_do
(
'addtag'
,
'closest'
,
x
,
y
,
halo
,
start
)
self
.
_do
(
'addtag'
,
'closest'
,
x
,
y
,
halo
,
start
)
def
addtag_enclosed
(
self
,
x1
,
y1
,
x2
,
y2
):
def
addtag_enclosed
(
self
,
x1
,
y1
,
x2
,
y2
):
self
.
_do
(
'addtag'
,
'enclosed'
,
x1
,
y1
,
x2
,
y2
)
self
.
_do
(
'addtag'
,
'enclosed'
,
x1
,
y1
,
x2
,
y2
)
def
addtag_overlapping
(
self
,
x1
,
y1
,
x2
,
y2
):
def
addtag_overlapping
(
self
,
x1
,
y1
,
x2
,
y2
):
self
.
_do
(
'addtag'
,
'overlapping'
,
x1
,
y1
,
x2
,
y2
)
self
.
_do
(
'addtag'
,
'overlapping'
,
x1
,
y1
,
x2
,
y2
)
def
addtag_withtag
(
self
,
tagOrId
):
def
addtag_withtag
(
self
,
tagOrId
):
self
.
_do
(
'addtag'
,
'withtag'
,
tagOrId
)
self
.
_do
(
'addtag'
,
'withtag'
,
tagOrId
)
def
bbox
(
self
):
def
bbox
(
self
):
return
self
.
canvas
.
_getints
(
self
.
_do
(
'bbox'
))
return
self
.
canvas
.
_getints
(
self
.
_do
(
'bbox'
))
def
bind
(
self
,
sequence
=
None
,
command
=
None
,
add
=
None
):
def
bind
(
self
,
sequence
=
None
,
command
=
None
,
add
=
None
):
return
self
.
canvas
.
tag_bind
(
self
.
id
,
sequence
,
command
,
add
)
return
self
.
canvas
.
tag_bind
(
self
.
id
,
sequence
,
command
,
add
)
def
unbind
(
self
,
sequence
,
funcid
=
None
):
def
unbind
(
self
,
sequence
,
funcid
=
None
):
self
.
canvas
.
tag_unbind
(
self
.
id
,
sequence
,
funcid
)
self
.
canvas
.
tag_unbind
(
self
.
id
,
sequence
,
funcid
)
def
coords
(
self
,
*
pts
):
def
coords
(
self
,
*
pts
):
return
self
.
_do
(
'coords'
,
pts
)
return
self
.
_do
(
'coords'
,
pts
)
def
dchars
(
self
,
first
,
last
=
None
):
def
dchars
(
self
,
first
,
last
=
None
):
self
.
_do
(
'dchars'
,
first
,
last
)
self
.
_do
(
'dchars'
,
first
,
last
)
def
delete
(
self
):
def
delete
(
self
):
self
.
_do
(
'delete'
)
self
.
_do
(
'delete'
)
def
dtag
(
self
,
tagToDelete
=
None
):
def
dtag
(
self
,
tagToDelete
=
None
):
self
.
_do
(
'dtag'
,
tagToDelete
)
self
.
_do
(
'dtag'
,
tagToDelete
)
def
focus
(
self
):
def
focus
(
self
):
self
.
_do
(
'focus'
)
self
.
_do
(
'focus'
)
def
gettags
(
self
):
def
gettags
(
self
):
return
self
.
canvas
.
tk
.
splitlist
(
self
.
_do
(
'gettags'
,
self
.
tag
))
return
self
.
canvas
.
tk
.
splitlist
(
self
.
_do
(
'gettags'
,
self
.
tag
))
def
icursor
(
self
,
index
):
def
icursor
(
self
,
index
):
return
self
.
_do
(
'icursor'
,
index
)
return
self
.
_do
(
'icursor'
,
index
)
def
index
(
self
,
index
):
def
index
(
self
,
index
):
return
self
.
canvas
.
tk
.
getint
(
self
.
_do
(
'index'
,
index
))
return
self
.
canvas
.
tk
.
getint
(
self
.
_do
(
'index'
,
index
))
def
insert
(
self
,
beforeThis
,
string
):
def
insert
(
self
,
beforeThis
,
string
):
self
.
_do
(
'insert'
,
beforeThis
,
string
)
self
.
_do
(
'insert'
,
beforeThis
,
string
)
def
config
(
self
,
cnf
=
{},
**
kw
):
def
config
(
self
,
cnf
=
{},
**
kw
):
return
self
.
canvas
.
itemconfigure
(
self
.
tag
,
_cnfmerge
((
cnf
,
kw
)))
return
self
.
canvas
.
itemconfigure
(
self
.
tag
,
_cnfmerge
((
cnf
,
kw
)))
def
lower
(
self
,
belowThis
=
None
):
def
lower
(
self
,
belowThis
=
None
):
self
.
_do
(
'tag_lower'
,
belowThis
)
self
.
_do
(
'tag_lower'
,
belowThis
)
def
move
(
self
,
xAmount
,
yAmount
):
def
move
(
self
,
xAmount
,
yAmount
):
self
.
_do
(
'move'
,
xAmount
,
yAmount
)
self
.
_do
(
'move'
,
xAmount
,
yAmount
)
def
tkraise
(
self
,
aboveThis
=
None
):
def
tkraise
(
self
,
aboveThis
=
None
):
self
.
_do
(
'tag_raise'
,
aboveThis
)
self
.
_do
(
'tag_raise'
,
aboveThis
)
lift
=
tkraise
lift
=
tkraise
def
scale
(
self
,
xOrigin
,
yOrigin
,
xScale
,
yScale
):
def
scale
(
self
,
xOrigin
,
yOrigin
,
xScale
,
yScale
):
self
.
_do
(
'scale'
,
xOrigin
,
yOrigin
,
xScale
,
yScale
)
self
.
_do
(
'scale'
,
xOrigin
,
yOrigin
,
xScale
,
yScale
)
def
select_adjust
(
self
,
index
):
def
select_adjust
(
self
,
index
):
self
.
canvas
.
_do
(
'select'
,
(
'adjust'
,
self
.
tag
,
index
))
self
.
canvas
.
_do
(
'select'
,
(
'adjust'
,
self
.
tag
,
index
))
def
select_from
(
self
,
index
):
def
select_from
(
self
,
index
):
self
.
canvas
.
_do
(
'select'
,
(
'from'
,
self
.
tag
,
index
))
self
.
canvas
.
_do
(
'select'
,
(
'from'
,
self
.
tag
,
index
))
def
select_to
(
self
,
index
):
def
select_to
(
self
,
index
):
self
.
canvas
.
_do
(
'select'
,
(
'to'
,
self
.
tag
,
index
))
self
.
canvas
.
_do
(
'select'
,
(
'to'
,
self
.
tag
,
index
))
def
type
(
self
):
def
type
(
self
):
return
self
.
_do
(
'type'
)
return
self
.
_do
(
'type'
)
Lib/lib-tk/Dialog.py
View file @
7c6c100b
...
@@ -4,46 +4,46 @@ from Tkinter import *
...
@@ -4,46 +4,46 @@ from Tkinter import *
from
Tkinter
import
_cnfmerge
from
Tkinter
import
_cnfmerge
if
TkVersion
<=
3.6
:
if
TkVersion
<=
3.6
:
DIALOG_ICON
=
'warning'
DIALOG_ICON
=
'warning'
else
:
else
:
DIALOG_ICON
=
'questhead'
DIALOG_ICON
=
'questhead'
class
Dialog
(
Widget
):
class
Dialog
(
Widget
):
def
__init__
(
self
,
master
=
None
,
cnf
=
{},
**
kw
):
def
__init__
(
self
,
master
=
None
,
cnf
=
{},
**
kw
):
cnf
=
_cnfmerge
((
cnf
,
kw
))
cnf
=
_cnfmerge
((
cnf
,
kw
))
self
.
widgetName
=
'__dialog__'
self
.
widgetName
=
'__dialog__'
Widget
.
_setup
(
self
,
master
,
cnf
)
Widget
.
_setup
(
self
,
master
,
cnf
)
self
.
num
=
self
.
tk
.
getint
(
self
.
num
=
self
.
tk
.
getint
(
apply
(
self
.
tk
.
call
,
apply
(
self
.
tk
.
call
,
(
'tk_dialog'
,
self
.
_w
,
(
'tk_dialog'
,
self
.
_w
,
cnf
[
'title'
],
cnf
[
'text'
],
cnf
[
'title'
],
cnf
[
'text'
],
cnf
[
'bitmap'
],
cnf
[
'default'
])
cnf
[
'bitmap'
],
cnf
[
'default'
])
+
cnf
[
'strings'
]))
+
cnf
[
'strings'
]))
try
:
Widget
.
destroy
(
self
)
try
:
Widget
.
destroy
(
self
)
except
TclError
:
pass
except
TclError
:
pass
def
destroy
(
self
):
pass
def
destroy
(
self
):
pass
def
_test
():
def
_test
():
d
=
Dialog
(
None
,
{
'title'
:
'File Modified'
,
d
=
Dialog
(
None
,
{
'title'
:
'File Modified'
,
'text'
:
'text'
:
'File "Python.h" has been modified'
'File "Python.h" has been modified'
' since the last time it was saved.'
' since the last time it was saved.'
' Do you want to save it before'
' Do you want to save it before'
' exiting the application.'
,
' exiting the application.'
,
'bitmap'
:
DIALOG_ICON
,
'bitmap'
:
DIALOG_ICON
,
'default'
:
0
,
'default'
:
0
,
'strings'
:
(
'Save File'
,
'strings'
:
(
'Save File'
,
'Discard Changes'
,
'Discard Changes'
,
'Return to Editor'
)})
'Return to Editor'
)})
print
d
.
num
print
d
.
num
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
t
=
Button
(
None
,
{
'text'
:
'Test'
,
t
=
Button
(
None
,
{
'text'
:
'Test'
,
'command'
:
_test
,
'command'
:
_test
,
Pack
:
{}})
Pack
:
{}})
q
=
Button
(
None
,
{
'text'
:
'Quit'
,
q
=
Button
(
None
,
{
'text'
:
'Quit'
,
'command'
:
t
.
quit
,
'command'
:
t
.
quit
,
Pack
:
{}})
Pack
:
{}})
t
.
mainloop
()
t
.
mainloop
()
Lib/lib-tk/ScrolledText.py
View file @
7c6c100b
...
@@ -14,26 +14,26 @@ from Tkinter import *
...
@@ -14,26 +14,26 @@ from Tkinter import *
from
Tkinter
import
_cnfmerge
from
Tkinter
import
_cnfmerge
class
ScrolledText
(
Text
):
class
ScrolledText
(
Text
):
def
__init__
(
self
,
master
=
None
,
cnf
=
None
,
**
kw
):
def
__init__
(
self
,
master
=
None
,
cnf
=
None
,
**
kw
):
if
cnf
is
None
:
if
cnf
is
None
:
cnf
=
{}
cnf
=
{}
if
kw
:
if
kw
:
cnf
=
_cnfmerge
((
cnf
,
kw
))
cnf
=
_cnfmerge
((
cnf
,
kw
))
fcnf
=
{}
fcnf
=
{}
for
k
in
cnf
.
keys
():
for
k
in
cnf
.
keys
():
if
type
(
k
)
==
ClassType
or
k
==
'name'
:
if
type
(
k
)
==
ClassType
or
k
==
'name'
:
fcnf
[
k
]
=
cnf
[
k
]
fcnf
[
k
]
=
cnf
[
k
]
del
cnf
[
k
]
del
cnf
[
k
]
self
.
frame
=
apply
(
Frame
,
(
master
,),
fcnf
)
self
.
frame
=
apply
(
Frame
,
(
master
,),
fcnf
)
self
.
vbar
=
Scrollbar
(
self
.
frame
,
name
=
'vbar'
)
self
.
vbar
=
Scrollbar
(
self
.
frame
,
name
=
'vbar'
)
self
.
vbar
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
self
.
vbar
.
pack
(
side
=
RIGHT
,
fill
=
Y
)
cnf
[
'name'
]
=
'text'
cnf
[
'name'
]
=
'text'
apply
(
Text
.
__init__
,
(
self
,
self
.
frame
),
cnf
)
apply
(
Text
.
__init__
,
(
self
,
self
.
frame
),
cnf
)
self
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
self
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
self
[
'yscrollcommand'
]
=
self
.
vbar
.
set
self
[
'yscrollcommand'
]
=
self
.
vbar
.
set
self
.
vbar
[
'command'
]
=
self
.
yview
self
.
vbar
[
'command'
]
=
self
.
yview
# Copy Pack methods of self.frame -- hack!
# Copy Pack methods of self.frame -- hack!
for
m
in
Pack
.
__dict__
.
keys
():
for
m
in
Pack
.
__dict__
.
keys
():
if
m
[
0
]
!=
'_'
and
m
!=
'config'
and
m
!=
'configure'
:
if
m
[
0
]
!=
'_'
and
m
!=
'config'
and
m
!=
'configure'
:
setattr
(
self
,
m
,
getattr
(
self
.
frame
,
m
))
setattr
(
self
,
m
,
getattr
(
self
.
frame
,
m
))
Lib/lib-tk/Tkdnd.py
View file @
7c6c100b
"""Drag-and-drop support for Tkinter.
"""Drag-and-drop support for Tkinter.
This is very preliminary. I currently only support dnd *within* one
This is very preliminary. I currently only support dnd *within* one
application, between different windows (or within the same window).
application, between different windows (or within the same window).
I an trying to make this as generic as possible -- not dependent on
I an trying to make this as generic as possible -- not dependent on
the use of a particular widget or icon type, etc. I also hope that
the use of a particular widget or icon type, etc. I also hope that
this will work with Pmw.
this will work with Pmw.
To enable an object to be dragged, you must create an event binding
To enable an object to be dragged, you must create an event binding
for it that starts the drag-and-drop process. Typically, you should
for it that starts the drag-and-drop process. Typically, you should
bind <ButtonPress> to a callback function that you write. The function
bind <ButtonPress> to a callback function that you write. The function
...
@@ -20,11 +20,11 @@ When a drag-and-drop is already in process for the Tk interpreter, the
...
@@ -20,11 +20,11 @@ When a drag-and-drop is already in process for the Tk interpreter, the
call is *ignored*; this normally averts starting multiple simultaneous
call is *ignored*; this normally averts starting multiple simultaneous
dnd processes, e.g. because different button callbacks all
dnd processes, e.g. because different button callbacks all
dnd_start().
dnd_start().
The object is *not* necessarily a widget -- it can be any
The object is *not* necessarily a widget -- it can be any
application-specific object that is meaningful to potential
application-specific object that is meaningful to potential
drag-and-drop targets.
drag-and-drop targets.
Potential drag-and-drop targets are discovered as follows. Whenever
Potential drag-and-drop targets are discovered as follows. Whenever
the mouse moves, and at the start and end of a drag-and-drop move, the
the mouse moves, and at the start and end of a drag-and-drop move, the
Tk widget directly under the mouse is inspected. This is the target
Tk widget directly under the mouse is inspected. This is the target
...
@@ -43,34 +43,34 @@ target widget, and the search for a target object is repeated from
...
@@ -43,34 +43,34 @@ target widget, and the search for a target object is repeated from
there. If necessary, the search is repeated all the way up to the
there. If necessary, the search is repeated all the way up to the
root widget. If none of the target widgets can produce a target
root widget. If none of the target widgets can produce a target
object, there is no target object (the target object is None).
object, there is no target object (the target object is None).
The target object thus produced, if any, is called the new target
The target object thus produced, if any, is called the new target
object. It is compared with the old target object (or None, if there
object. It is compared with the old target object (or None, if there
was no old target widget). There are several cases ('source' is the
was no old target widget). There are several cases ('source' is the
source object, and 'event' is the most recent event object):
source object, and 'event' is the most recent event object):
- Both the old and new target objects are None. Nothing happens.
- Both the old and new target objects are None. Nothing happens.
- The old and new target objects are the same object. Its method
- The old and new target objects are the same object. Its method
dnd_motion(source, event) is called.
dnd_motion(source, event) is called.
- The old target object was None, and the new target object is not
- The old target object was None, and the new target object is not
None. The new target object's method dnd_enter(source, event) is
None. The new target object's method dnd_enter(source, event) is
called.
called.
- The new target object is None, and the old target object is not
- The new target object is None, and the old target object is not
None. The old target object's method dnd_leave(source, event) is
None. The old target object's method dnd_leave(source, event) is
called.
called.
- The old and new target objects differ and neither is None. The old
- The old and new target objects differ and neither is None. The old
target object's method dnd_leave(source, event), and then the new
target object's method dnd_leave(source, event), and then the new
target object's method dnd_enter(source, event) is called.
target object's method dnd_enter(source, event) is called.
Once this is done, the new target object replaces the old one, and the
Once this is done, the new target object replaces the old one, and the
Tk mainloop proceeds. The return value of the methods mentioned above
Tk mainloop proceeds. The return value of the methods mentioned above
is ignored; if they raise an exception, the normal exception handling
is ignored; if they raise an exception, the normal exception handling
mechanisms take over.
mechanisms take over.
The drag-and-drop processes can end in two ways: a final target object
The drag-and-drop processes can end in two ways: a final target object
is selected, or no final target object is selected. When a final
is selected, or no final target object is selected. When a final
target object is selected, it will always have been notified of the
target object is selected, it will always have been notified of the
...
@@ -79,7 +79,7 @@ above, and possibly one or more calls to its dnd_motion() method; its
...
@@ -79,7 +79,7 @@ above, and possibly one or more calls to its dnd_motion() method; its
dnd_leave() method has not been called since the last call to
dnd_leave() method has not been called since the last call to
dnd_enter(). The target is notified of the drop by a call to its
dnd_enter(). The target is notified of the drop by a call to its
method dnd_commit(source, event).
method dnd_commit(source, event).
If no final target object is selected, and there was an old target
If no final target object is selected, and there was an old target
object, its dnd_leave(source, event) method is called to complete the
object, its dnd_leave(source, event) method is called to complete the
dnd sequence.
dnd sequence.
...
...
Lib/lib-tk/Tkinter.py
View file @
7c6c100b
...
@@ -3086,4 +3086,3 @@ def _test():
...
@@ -3086,4 +3086,3 @@ def _test():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
_test
()
_test
()
Lib/lib-tk/tkCommonDialog.py
View file @
7c6c100b
...
@@ -63,4 +63,3 @@ class Dialog:
...
@@ -63,4 +63,3 @@ class Dialog:
pass
pass
return
s
return
s
Lib/lib-tk/tkFont.py
View file @
7c6c100b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#
#
# FIXME: should add 'displayof' option where relevant (actual, families,
# FIXME: should add 'displayof' option where relevant (actual, families,
# measure, and metrics)
# measure, and metrics)
#
#
# Copyright (c) Secret Labs AB 1998.
# Copyright (c) Secret Labs AB 1998.
#
#
# info@pythonware.com
# info@pythonware.com
...
@@ -52,10 +52,10 @@ class Font:
...
@@ -52,10 +52,10 @@ class Font:
return
tuple
(
options
)
return
tuple
(
options
)
def
_get
(
self
,
args
):
def
_get
(
self
,
args
):
options
=
[]
options
=
[]
for
k
in
args
:
for
k
in
args
:
options
.
append
(
"-"
+
k
)
options
.
append
(
"-"
+
k
)
return
tuple
(
options
)
return
tuple
(
options
)
def
_mkdict
(
self
,
args
):
def
_mkdict
(
self
,
args
):
options
=
{}
options
=
{}
...
@@ -117,7 +117,7 @@ class Font:
...
@@ -117,7 +117,7 @@ class Font:
)
)
configure
=
config
configure
=
config
def
measure
(
self
,
text
):
def
measure
(
self
,
text
):
"Return text width"
"Return text width"
return
string
.
atoi
(
self
.
_call
(
"font"
,
"measure"
,
self
.
name
,
text
))
return
string
.
atoi
(
self
.
_call
(
"font"
,
"measure"
,
self
.
name
,
text
))
...
@@ -143,7 +143,7 @@ def families(root=None):
...
@@ -143,7 +143,7 @@ def families(root=None):
"Get font families (as a tuple)"
"Get font families (as a tuple)"
if
not
root
:
if
not
root
:
root
=
Tkinter
.
_default_root
root
=
Tkinter
.
_default_root
return
root
.
tk
.
splitlist
(
root
.
tk
.
call
(
"font"
,
"families"
))
return
root
.
tk
.
splitlist
(
root
.
tk
.
call
(
"font"
,
"families"
))
def
names
(
root
=
None
):
def
names
(
root
=
None
):
"Get names of defined fonts (as a tuple)"
"Get names of defined fonts (as a tuple)"
...
@@ -153,7 +153,7 @@ def names(root=None):
...
@@ -153,7 +153,7 @@ def names(root=None):
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# test stuff
# test stuff
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
root
=
Tkinter
.
Tk
()
root
=
Tkinter
.
Tk
()
...
@@ -186,7 +186,7 @@ if __name__ == "__main__":
...
@@ -186,7 +186,7 @@ if __name__ == "__main__":
fb
=
Font
(
font
=
w
[
"font"
]).
copy
()
fb
=
Font
(
font
=
w
[
"font"
]).
copy
()
fb
.
config
(
weight
=
BOLD
)
fb
.
config
(
weight
=
BOLD
)
w
.
config
(
font
=
fb
)
w
.
config
(
font
=
fb
)
Tkinter
.
mainloop
()
Tkinter
.
mainloop
()
Lib/lib-tk/tkSimpleDialog.py
View file @
7c6c100b
...
@@ -86,18 +86,18 @@ class Dialog(Toplevel):
...
@@ -86,18 +86,18 @@ class Dialog(Toplevel):
def
body
(
self
,
master
):
def
body
(
self
,
master
):
'''create dialog body.
'''create dialog body.
return widget that should have initial focus.
return widget that should have initial focus.
This method should be overridden, and is called
This method should be overridden, and is called
by the __init__ method.
by the __init__ method.
'''
'''
pass
pass
def
buttonbox
(
self
):
def
buttonbox
(
self
):
'''add standard button box.
'''add standard button box.
override if you don't want the standard buttons
override if you don't want the standard buttons
'''
'''
box
=
Frame
(
self
)
box
=
Frame
(
self
)
w
=
Button
(
box
,
text
=
"OK"
,
width
=
10
,
command
=
self
.
ok
,
default
=
ACTIVE
)
w
=
Button
(
box
,
text
=
"OK"
,
width
=
10
,
command
=
self
.
ok
,
default
=
ACTIVE
)
...
@@ -138,7 +138,7 @@ class Dialog(Toplevel):
...
@@ -138,7 +138,7 @@ class Dialog(Toplevel):
def
validate
(
self
):
def
validate
(
self
):
'''validate the data
'''validate the data
This method is called automatically to validate the data before the
This method is called automatically to validate the data before the
dialog is destroyed. By default, it always validates OK.
dialog is destroyed. By default, it always validates OK.
'''
'''
...
@@ -227,7 +227,7 @@ class _QueryDialog(Dialog):
...
@@ -227,7 +227,7 @@ class _QueryDialog(Dialog):
parent
=
self
parent
=
self
)
)
return
0
return
0
self
.
result
=
result
self
.
result
=
result
return
1
return
1
...
@@ -289,7 +289,7 @@ def askstring(title, prompt, **kw):
...
@@ -289,7 +289,7 @@ def askstring(title, prompt, **kw):
d
=
apply
(
_QueryString
,
(
title
,
prompt
),
kw
)
d
=
apply
(
_QueryString
,
(
title
,
prompt
),
kw
)
return
d
.
result
return
d
.
result
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
root
=
Tk
()
root
=
Tk
()
root
.
update
()
root
.
update
()
...
@@ -297,4 +297,3 @@ if __name__ == "__main__":
...
@@ -297,4 +297,3 @@ if __name__ == "__main__":
print
askinteger
(
"Spam"
,
"Egg count"
,
initialvalue
=
12
*
12
)
print
askinteger
(
"Spam"
,
"Egg count"
,
initialvalue
=
12
*
12
)
print
askfloat
(
"Spam"
,
"Egg weight
\
n
(in tons)"
,
minvalue
=
1
,
maxvalue
=
100
)
print
askfloat
(
"Spam"
,
"Egg weight
\
n
(in tons)"
,
minvalue
=
1
,
maxvalue
=
100
)
print
askstring
(
"Spam"
,
"Egg label"
)
print
askstring
(
"Spam"
,
"Egg label"
)
Lib/lib-tk/turtle.py
View file @
7c6c100b
...
@@ -108,7 +108,7 @@ class RawPen:
...
@@ -108,7 +108,7 @@ class RawPen:
def
write
(
self
,
arg
,
move
=
0
):
def
write
(
self
,
arg
,
move
=
0
):
x
,
y
=
start
=
self
.
_position
x
,
y
=
start
=
self
.
_position
x
=
x
-
1
# correction -- calibrated for Windows
x
=
x
-
1
# correction -- calibrated for Windows
item
=
self
.
_canvas
.
create_text
(
x
,
y
,
item
=
self
.
_canvas
.
create_text
(
x
,
y
,
text
=
str
(
arg
),
anchor
=
"sw"
,
text
=
str
(
arg
),
anchor
=
"sw"
,
fill
=
self
.
_color
)
fill
=
self
.
_color
)
self
.
_items
.
append
(
item
)
self
.
_items
.
append
(
item
)
...
@@ -258,7 +258,7 @@ class Pen(RawPen):
...
@@ -258,7 +258,7 @@ class Pen(RawPen):
_root
=
None
_root
=
None
_canvas
=
None
_canvas
=
None
root
.
destroy
()
root
.
destroy
()
def
_getpen
():
def
_getpen
():
global
_pen
global
_pen
...
...
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