Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
fc14ad99
Kaydet (Commit)
fc14ad99
authored
Haz 02, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #6181: Fixed minor bugs in tkinter.Listbox methods:
bbox(), curselection() and get().
üst
90441e85
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
29 deletions
+60
-29
__init__.py
Lib/tkinter/__init__.py
+6
-9
test_widgets.py
Lib/tkinter/test/test_tkinter/test_widgets.py
+42
-10
test_widgets.py
Lib/tkinter/test/test_ttk/test_widgets.py
+2
-10
widget_tests.py
Lib/tkinter/test/widget_tests.py
+10
-0
No files found.
Lib/tkinter/__init__.py
Dosyayı görüntüle @
fc14ad99
...
...
@@ -2586,22 +2586,19 @@ class Listbox(Widget, XView, YView):
def
activate
(
self
,
index
):
"""Activate item identified by INDEX."""
self
.
tk
.
call
(
self
.
_w
,
'activate'
,
index
)
def
bbox
(
self
,
*
args
):
def
bbox
(
self
,
index
):
"""Return a tuple of X1,Y1,X2,Y2 coordinates for a rectangle
which encloses the item identified by index in ARGS."""
return
self
.
_getints
(
self
.
tk
.
call
((
self
.
_w
,
'bbox'
)
+
args
))
or
None
which encloses the item identified by the given index."""
return
self
.
_getints
(
self
.
tk
.
call
(
self
.
_w
,
'bbox'
,
index
))
or
None
def
curselection
(
self
):
"""Return list of indices of currently selected item."""
# XXX Ought to apply self._getints()...
return
self
.
tk
.
splitlist
(
self
.
tk
.
call
(
self
.
_w
,
'curselection'
))
"""Return the indices of currently selected item."""
return
self
.
_getints
(
self
.
tk
.
call
(
self
.
_w
,
'curselection'
))
or
()
def
delete
(
self
,
first
,
last
=
None
):
"""Delete items from FIRST to LAST (included)."""
self
.
tk
.
call
(
self
.
_w
,
'delete'
,
first
,
last
)
def
get
(
self
,
first
,
last
=
None
):
"""Get list of items from FIRST to LAST (included)."""
if
last
:
if
last
is
not
None
:
return
self
.
tk
.
splitlist
(
self
.
tk
.
call
(
self
.
_w
,
'get'
,
first
,
last
))
else
:
...
...
Lib/tkinter/test/test_tkinter/test_widgets.py
Dosyayı görüntüle @
fc14ad99
...
...
@@ -467,11 +467,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
def
test_bbox
(
self
):
widget
=
self
.
create
()
bbox
=
widget
.
bbox
(
0
)
self
.
assertEqual
(
len
(
bbox
),
4
)
for
item
in
bbox
:
self
.
assertIsInstance
(
item
,
int
)
self
.
assertIsBoundingBox
(
widget
.
bbox
(
0
))
self
.
assertRaises
(
tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
tkinter
.
TclError
,
widget
.
bbox
,
None
)
self
.
assertRaises
(
TypeError
,
widget
.
bbox
)
...
...
@@ -624,11 +620,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def
test_bbox
(
self
):
widget
=
self
.
create
()
bbox
=
widget
.
bbox
(
'1.1'
)
self
.
assertEqual
(
len
(
bbox
),
4
)
for
item
in
bbox
:
self
.
assertIsInstance
(
item
,
int
)
self
.
assertIsBoundingBox
(
widget
.
bbox
(
'1.1'
))
self
.
assertIsNone
(
widget
.
bbox
(
'end'
))
self
.
assertRaises
(
tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
tkinter
.
TclError
,
widget
.
bbox
,
None
)
...
...
@@ -785,6 +777,46 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
def
test_itemconfigure_selectforeground
(
self
):
self
.
check_itemconfigure
(
'selectforeground'
,
'#654321'
)
def
test_box
(
self
):
lb
=
self
.
create
()
lb
.
insert
(
0
,
*
(
'el
%
d'
%
i
for
i
in
range
(
8
)))
lb
.
pack
()
self
.
assertIsBoundingBox
(
lb
.
bbox
(
0
))
self
.
assertIsNone
(
lb
.
bbox
(
-
1
))
self
.
assertIsNone
(
lb
.
bbox
(
10
))
self
.
assertRaises
(
TclError
,
lb
.
bbox
,
'noindex'
)
self
.
assertRaises
(
TclError
,
lb
.
bbox
,
None
)
self
.
assertRaises
(
TypeError
,
lb
.
bbox
)
self
.
assertRaises
(
TypeError
,
lb
.
bbox
,
0
,
1
)
def
test_curselection
(
self
):
lb
=
self
.
create
()
lb
.
insert
(
0
,
*
(
'el
%
d'
%
i
for
i
in
range
(
8
)))
lb
.
selection_clear
(
0
,
tkinter
.
END
)
lb
.
selection_set
(
2
,
4
)
lb
.
selection_set
(
6
)
self
.
assertEqual
(
lb
.
curselection
(),
(
2
,
3
,
4
,
6
))
self
.
assertRaises
(
TypeError
,
lb
.
curselection
,
0
)
def
test_get
(
self
):
lb
=
self
.
create
()
lb
.
insert
(
0
,
*
(
'el
%
d'
%
i
for
i
in
range
(
8
)))
self
.
assertEqual
(
lb
.
get
(
0
),
'el0'
)
self
.
assertEqual
(
lb
.
get
(
3
),
'el3'
)
self
.
assertEqual
(
lb
.
get
(
'end'
),
'el7'
)
self
.
assertEqual
(
lb
.
get
(
8
),
''
)
self
.
assertEqual
(
lb
.
get
(
-
1
),
''
)
self
.
assertEqual
(
lb
.
get
(
3
,
5
),
(
'el3'
,
'el4'
,
'el5'
))
self
.
assertEqual
(
lb
.
get
(
5
,
'end'
),
(
'el5'
,
'el6'
,
'el7'
))
self
.
assertEqual
(
lb
.
get
(
5
,
0
),
())
self
.
assertEqual
(
lb
.
get
(
0
,
0
),
(
'el0'
,))
self
.
assertRaises
(
TclError
,
lb
.
get
,
'noindex'
)
self
.
assertRaises
(
TclError
,
lb
.
get
,
None
)
self
.
assertRaises
(
TypeError
,
lb
.
get
)
self
.
assertRaises
(
TclError
,
lb
.
get
,
'end'
,
'noindex'
)
self
.
assertRaises
(
TypeError
,
lb
.
get
,
1
,
2
,
3
)
self
.
assertRaises
(
TclError
,
lb
.
get
,
2.4
)
@add_standard_options
(
PixelSizeTests
,
StandardOptionsTests
)
class
ScaleTest
(
AbstractWidgetTest
,
unittest
.
TestCase
):
...
...
Lib/tkinter/test/test_ttk/test_widgets.py
Dosyayı görüntüle @
fc14ad99
...
...
@@ -460,10 +460,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def
test_bbox
(
self
):
self
.
assertEqual
(
len
(
self
.
entry
.
bbox
(
0
)),
4
)
for
item
in
self
.
entry
.
bbox
(
0
):
self
.
assertIsInstance
(
item
,
int
)
self
.
assertIsBoundingBox
(
self
.
entry
.
bbox
(
0
))
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
entry
.
bbox
,
'noindex'
)
self
.
assertRaises
(
tkinter
.
TclError
,
self
.
entry
.
bbox
,
None
)
...
...
@@ -1216,12 +1213,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self
.
assertTrue
(
children
)
bbox
=
self
.
tv
.
bbox
(
children
[
0
])
self
.
assertEqual
(
len
(
bbox
),
4
)
self
.
assertIsInstance
(
bbox
,
tuple
)
for
item
in
bbox
:
if
not
isinstance
(
item
,
int
):
self
.
fail
(
"Invalid bounding box:
%
s"
%
bbox
)
break
self
.
assertIsBoundingBox
(
bbox
)
# compare width in bboxes
self
.
tv
[
'columns'
]
=
[
'test'
]
...
...
Lib/tkinter/test/widget_tests.py
Dosyayı görüntüle @
fc14ad99
...
...
@@ -202,6 +202,16 @@ class AbstractWidgetTest:
def
checkVariableParam
(
self
,
widget
,
name
,
var
):
self
.
checkParam
(
widget
,
name
,
var
,
conv
=
str
)
def
assertIsBoundingBox
(
self
,
bbox
):
self
.
assertIsNotNone
(
bbox
)
self
.
assertIsInstance
(
bbox
,
tuple
)
if
len
(
bbox
)
!=
4
:
self
.
fail
(
'Invalid bounding box:
%
r'
%
(
bbox
,))
for
item
in
bbox
:
if
not
isinstance
(
item
,
int
):
self
.
fail
(
'Invalid bounding box:
%
r'
%
(
bbox
,))
break
class
StandardOptionsTests
:
STANDARD_OPTIONS
=
(
...
...
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