Commit 7a025823 authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.

parent a6a8a4f5
import unittest import unittest
import Tkinter as tkinter import Tkinter as tkinter
from Tkinter import TclError
import ttk import ttk
from test.test_support import requires, run_unittest from test.test_support import requires, run_unittest
import sys import sys
...@@ -1564,6 +1565,21 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase): ...@@ -1564,6 +1565,21 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
'blue') 'blue')
self.assertIsInstance(self.tv.tag_configure('test'), dict) self.assertIsInstance(self.tv.tag_configure('test'), dict)
def test_tag_has(self):
item1 = self.tv.insert('', 'end', text='Item 1', tags=['tag1'])
item2 = self.tv.insert('', 'end', text='Item 2', tags=['tag2'])
self.assertRaises(TypeError, self.tv.tag_has)
self.assertRaises(TclError, self.tv.tag_has, 'tag1', 'non-existing')
self.assertTrue(self.tv.tag_has('tag1', item1))
self.assertFalse(self.tv.tag_has('tag1', item2))
self.assertFalse(self.tv.tag_has('tag2', item1))
self.assertTrue(self.tv.tag_has('tag2', item2))
self.assertFalse(self.tv.tag_has('tag3', item1))
self.assertFalse(self.tv.tag_has('tag3', item2))
self.assertEqual(self.tv.tag_has('tag1'), (item1,))
self.assertEqual(self.tv.tag_has('tag2'), (item2,))
self.assertEqual(self.tv.tag_has('tag3'), ())
@add_standard_options(StandardTtkOptionsTests) @add_standard_options(StandardTtkOptionsTests)
class SeparatorTest(AbstractWidgetTest, unittest.TestCase): class SeparatorTest(AbstractWidgetTest, unittest.TestCase):
......
...@@ -1458,7 +1458,11 @@ class Treeview(Widget, Tkinter.XView, Tkinter.YView): ...@@ -1458,7 +1458,11 @@ class Treeview(Widget, Tkinter.XView, Tkinter.YView):
all items which have the specified tag. all items which have the specified tag.
* Availability: Tk 8.6""" * Availability: Tk 8.6"""
return self.tk.getboolean( if item is None:
return self.tk.splitlist(
self.tk.call(self._w, "tag", "has", tagname))
else:
return self.tk.getboolean(
self.tk.call(self._w, "tag", "has", tagname, item)) self.tk.call(self._w, "tag", "has", tagname, item))
......
...@@ -37,6 +37,8 @@ Core and Builtins ...@@ -37,6 +37,8 @@ Core and Builtins
Library Library
------- -------
- Issue #22769: Fixed ttk.Treeview.tag_has() when called without arguments.
- Issue #22787: Allow the keyfile argument of SSLContext.load_cert_chain to be - Issue #22787: Allow the keyfile argument of SSLContext.load_cert_chain to be
None. None.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment