import unittest
import tkinter
-from tkinter import ttk
+from tkinter import ttk, TclError
from test.support import requires
import sys
'blue')
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)
class SeparatorTest(AbstractWidgetTest, unittest.TestCase):
all items which have the specified tag.
* 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))