Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d68f18

Browse files
Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
2 parents b9f3114 + 42a4366 commit 2d68f18

6 files changed

Lines changed: 183 additions & 138 deletions

File tree

Lib/tkinter/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,9 @@ def __setitem__(self, key, value):
13361336
self.configure({key: value})
13371337
def keys(self):
13381338
"""Return a list of all resource names of this widget."""
1339-
return [x[0][1:] for x in
1340-
self.tk.splitlist(self.tk.call(self._w, 'configure'))]
1339+
splitlist = self.tk.splitlist
1340+
return [splitlist(x)[0][1:] for x in
1341+
splitlist(self.tk.call(self._w, 'configure'))]
13411342
def __str__(self):
13421343
"""Return the window path name of this widget."""
13431344
return self._w

Lib/tkinter/test/test_tkinter/test_geometry_managers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
class PackTest(AbstractWidgetTest, unittest.TestCase):
1414

15+
test_keys = None
16+
1517
def create2(self):
1618
pack = tkinter.Toplevel(self.root, name='pack')
1719
pack.wm_geometry('300x200+0+0')
@@ -276,6 +278,8 @@ def test_pack_slaves(self):
276278

277279
class PlaceTest(AbstractWidgetTest, unittest.TestCase):
278280

281+
test_keys = None
282+
279283
def create2(self):
280284
t = tkinter.Toplevel(self.root, width=300, height=200, bd=0)
281285
t.wm_geometry('300x200+0+0')
@@ -478,6 +482,8 @@ def test_place_slaves(self):
478482

479483
class GridTest(AbstractWidgetTest, unittest.TestCase):
480484

485+
test_keys = None
486+
481487
def tearDown(self):
482488
cols, rows = self.root.grid_size()
483489
for i in range(cols + 1):

Lib/tkinter/test/test_tkinter/test_widgets.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class FrameTest(AbstractToplevelTest, unittest.TestCase):
103103
'background', 'borderwidth',
104104
'class', 'colormap', 'container', 'cursor', 'height',
105105
'highlightbackground', 'highlightcolor', 'highlightthickness',
106-
'relief', 'takefocus', 'visual', 'width',
106+
'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
107107
)
108108

109109
def create(self, **kwargs):
@@ -637,7 +637,7 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
637637
'highlightbackground', 'highlightcolor', 'highlightthickness',
638638
'insertbackground', 'insertborderwidth',
639639
'insertofftime', 'insertontime', 'insertwidth',
640-
'relief', 'scrollregion',
640+
'offset', 'relief', 'scrollregion',
641641
'selectbackground', 'selectborderwidth', 'selectforeground',
642642
'state', 'takefocus',
643643
'xscrollcommand', 'xscrollincrement',
@@ -659,6 +659,15 @@ def test_confine(self):
659659
widget = self.create()
660660
self.checkBooleanParam(widget, 'confine')
661661

662+
def test_offset(self):
663+
widget = self.create()
664+
self.assertEqual(widget['offset'], '0,0')
665+
self.checkParams(widget, 'offset',
666+
'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center')
667+
self.checkParam(widget, 'offset', '10,20')
668+
self.checkParam(widget, 'offset', '#5,6')
669+
self.checkInvalidParam(widget, 'offset', 'spam')
670+
662671
def test_scrollregion(self):
663672
widget = self.create()
664673
self.checkParam(widget, 'scrollregion', '0 0 200 150')

0 commit comments

Comments
 (0)