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
f94686f6
Commit
f94686f6
authored
Jun 02, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #6181: Fixed minor bugs in tkinter.Listbox methods:
bbox(), curselection() and get().
parent
417367a4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
29 deletions
+60
-29
Lib/lib-tk/Tkinter.py
Lib/lib-tk/Tkinter.py
+6
-9
Lib/lib-tk/test/test_tkinter/test_widgets.py
Lib/lib-tk/test/test_tkinter/test_widgets.py
+42
-10
Lib/lib-tk/test/test_ttk/test_widgets.py
Lib/lib-tk/test/test_ttk/test_widgets.py
+2
-10
Lib/lib-tk/test/widget_tests.py
Lib/lib-tk/test/widget_tests.py
+10
-0
No files found.
Lib/lib-tk/Tkinter.py
View file @
f94686f6
...
@@ -2569,22 +2569,19 @@ class Listbox(Widget, XView, YView):
...
@@ -2569,22 +2569,19 @@ class Listbox(Widget, XView, YView):
def activate(self, index):
def activate(self, index):
"""
Activate
item
identified
by
INDEX
.
"""
"""
Activate
item
identified
by
INDEX
.
"""
self.tk.call(self._w, 'activate', 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
"""
Return
a
tuple
of
X1
,
Y1
,
X2
,
Y2
coordinates
for
a
rectangle
which
encloses
the
item
identified
by
index
in
ARGS
.
"""
which
encloses
the
item
identified
by
the
given
index
.
"""
return self._getints(
return self._getints(self.tk.call(self._w, 'bbox', index)) or None
self.tk.call((self._w, 'bbox') + args)) or None
def curselection(self):
def curselection(self):
"""
Return
list
of
indices
of
currently
selected
item
.
"""
"""
Return
the
indices
of
currently
selected
item
.
"""
# XXX Ought to apply self._getints()...
return self._getints(self.tk.call(self._w, 'curselection')) or ()
return self.tk.splitlist(self.tk.call(
self._w, 'curselection'))
def delete(self, first, last=None):
def delete(self, first, last=None):
"""
Delete
items
from
FIRST
to
LAST
(
included
).
"""
"""
Delete
items
from
FIRST
to
LAST
(
included
).
"""
self.tk.call(self._w, 'delete', first, last)
self.tk.call(self._w, 'delete', first, last)
def get(self, first, last=None):
def get(self, first, last=None):
"""
Get
list
of
items
from
FIRST
to
LAST
(
included
).
"""
"""
Get
list
of
items
from
FIRST
to
LAST
(
included
).
"""
if last:
if last
is not None
:
return self.tk.splitlist(self.tk.call(
return self.tk.splitlist(self.tk.call(
self._w, 'get', first, last))
self._w, 'get', first, last))
else:
else:
...
...
Lib/lib-tk/test/test_tkinter/test_widgets.py
View file @
f94686f6
...
@@ -464,11 +464,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
...
@@ -464,11 +464,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
def
test_bbox
(
self
):
def
test_bbox
(
self
):
widget
=
self
.
create
()
widget
=
self
.
create
()
bbox
=
widget
.
bbox
(
0
)
self
.
assertIsBoundingBox
(
widget
.
bbox
(
0
))
self
.
assertEqual
(
len
(
bbox
),
4
)
for
item
in
bbox
:
self
.
assertIsInstance
(
item
,
int
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
None
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
None
)
self
.
assertRaises
(
TypeError
,
widget
.
bbox
)
self
.
assertRaises
(
TypeError
,
widget
.
bbox
)
...
@@ -621,11 +617,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
...
@@ -621,11 +617,7 @@ class TextTest(AbstractWidgetTest, unittest.TestCase):
def
test_bbox
(
self
):
def
test_bbox
(
self
):
widget
=
self
.
create
()
widget
=
self
.
create
()
bbox
=
widget
.
bbox
(
'1.1'
)
self
.
assertIsBoundingBox
(
widget
.
bbox
(
'1.1'
))
self
.
assertEqual
(
len
(
bbox
),
4
)
for
item
in
bbox
:
self
.
assertIsInstance
(
item
,
int
)
self
.
assertIsNone
(
widget
.
bbox
(
'end'
))
self
.
assertIsNone
(
widget
.
bbox
(
'end'
))
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
'noindex'
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
None
)
self
.
assertRaises
(
Tkinter
.
TclError
,
widget
.
bbox
,
None
)
...
@@ -782,6 +774,46 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
...
@@ -782,6 +774,46 @@ class ListboxTest(AbstractWidgetTest, unittest.TestCase):
def
test_itemconfigure_selectforeground
(
self
):
def
test_itemconfigure_selectforeground
(
self
):
self
.
check_itemconfigure
(
'selectforeground'
,
'#654321'
)
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
)
@
add_standard_options
(
PixelSizeTests
,
StandardOptionsTests
)
class
ScaleTest
(
AbstractWidgetTest
,
unittest
.
TestCase
):
class
ScaleTest
(
AbstractWidgetTest
,
unittest
.
TestCase
):
...
...
Lib/lib-tk/test/test_ttk/test_widgets.py
View file @
f94686f6
...
@@ -461,10 +461,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
...
@@ -461,10 +461,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def test_bbox(self):
def test_bbox(self):
self.assertEqual(len(self.entry.bbox(0)), 4)
self.assertIsBoundingBox(self.entry.bbox(0))
for item in self.entry.bbox(0):
self.assertIsInstance(item, int)
self.assertRaises(Tkinter.TclError, self.entry.bbox, '
noindex
')
self.assertRaises(Tkinter.TclError, self.entry.bbox, '
noindex
')
self.assertRaises(Tkinter.TclError, self.entry.bbox, None)
self.assertRaises(Tkinter.TclError, self.entry.bbox, None)
...
@@ -1217,12 +1214,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
...
@@ -1217,12 +1214,7 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
self
.
assertTrue
(
children
)
self
.
assertTrue
(
children
)
bbox
=
self
.
tv
.
bbox
(
children
[
0
])
bbox
=
self
.
tv
.
bbox
(
children
[
0
])
self
.
assertEqual
(
len
(
bbox
),
4
)
self
.
assertIsBoundingBox
(
bbox
)
self
.
assertIsInstance
(
bbox
,
tuple
)
for
item
in
bbox
:
if
not
isinstance
(
item
,
int
):
self
.
fail
(
"Invalid bounding box: %s"
%
bbox
)
break
# compare width in bboxes
# compare width in bboxes
self
.
tv
[
'columns'
]
=
[
'test'
]
self
.
tv
[
'columns'
]
=
[
'test'
]
...
...
Lib/lib-tk/test/widget_tests.py
View file @
f94686f6
...
@@ -221,6 +221,16 @@ class AbstractWidgetTest(object):
...
@@ -221,6 +221,16 @@ class AbstractWidgetTest(object):
def
checkVariableParam
(
self
,
widget
,
name
,
var
):
def
checkVariableParam
(
self
,
widget
,
name
,
var
):
self
.
checkParam
(
widget
,
name
,
var
,
conv
=
str
)
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
(
object
):
class
StandardOptionsTests
(
object
):
STANDARD_OPTIONS
=
(
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