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

Skip to content

Commit 42a4366

Browse files
Issue #26177: Fixed the keys() method for Canvas and Scrollbar widgets.
Added few missed tests for configure options.
1 parent 0554d83 commit 42a4366

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
@@ -1337,8 +1337,9 @@ def __setitem__(self, key, value):
13371337
self.configure({key: value})
13381338
def keys(self):
13391339
"""Return a list of all resource names of this widget."""
1340-
return [x[0][1:] for x in
1341-
self.tk.splitlist(self.tk.call(self._w, 'configure'))]
1340+
splitlist = self.tk.splitlist
1341+
return [splitlist(x)[0][1:] for x in
1342+
splitlist(self.tk.call(self._w, 'configure'))]
13421343
def __str__(self):
13431344
"""Return the window path name of this widget."""
13441345
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
@@ -102,7 +102,7 @@ class FrameTest(AbstractToplevelTest, unittest.TestCase):
102102
'background', 'borderwidth',
103103
'class', 'colormap', 'container', 'cursor', 'height',
104104
'highlightbackground', 'highlightcolor', 'highlightthickness',
105-
'relief', 'takefocus', 'visual', 'width',
105+
'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
106106
)
107107

108108
def create(self, **kwargs):
@@ -636,7 +636,7 @@ class CanvasTest(AbstractWidgetTest, unittest.TestCase):
636636
'highlightbackground', 'highlightcolor', 'highlightthickness',
637637
'insertbackground', 'insertborderwidth',
638638
'insertofftime', 'insertontime', 'insertwidth',
639-
'relief', 'scrollregion',
639+
'offset', 'relief', 'scrollregion',
640640
'selectbackground', 'selectborderwidth', 'selectforeground',
641641
'state', 'takefocus',
642642
'xscrollcommand', 'xscrollincrement',
@@ -658,6 +658,15 @@ def test_confine(self):
658658
widget = self.create()
659659
self.checkBooleanParam(widget, 'confine')
660660

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

0 commit comments

Comments
 (0)