(self)
| 211 | style.element_create('plain.newelem', 'from', 'spam') |
| 212 | |
| 213 | def test_element_create_image(self): |
| 214 | style = self.style |
| 215 | image = tkinter.PhotoImage(master=self.root, width=12, height=10) |
| 216 | style.element_create('block', 'image', image) |
| 217 | self.assertIn('block', style.element_names()) |
| 218 | |
| 219 | style.layout('TestLabel1', [('block', {'sticky': 'news'})]) |
| 220 | a = ttk.Label(self.root, style='TestLabel1') |
| 221 | a.pack(expand=True, fill='both') |
| 222 | self.assertEqual(a.winfo_reqwidth(), 12) |
| 223 | self.assertEqual(a.winfo_reqheight(), 10) |
| 224 | |
| 225 | imgfile = support.findfile('python.xbm', subdir='tkinterdata') |
| 226 | img1 = tkinter.BitmapImage(master=self.root, file=imgfile, |
| 227 | foreground='yellow', background='blue') |
| 228 | img2 = tkinter.BitmapImage(master=self.root, file=imgfile, |
| 229 | foreground='blue', background='yellow') |
| 230 | img3 = tkinter.BitmapImage(master=self.root, file=imgfile, |
| 231 | foreground='white', background='black') |
| 232 | style.element_create('TestButton.button', 'image', |
| 233 | img1, ('pressed', img2), ('active', img3), |
| 234 | border=(2, 4), sticky='we') |
| 235 | self.assertIn('TestButton.button', style.element_names()) |
| 236 | |
| 237 | style.layout('TestButton', [('TestButton.button', {'sticky': 'news'})]) |
| 238 | b = ttk.Button(self.root, style='TestButton') |
| 239 | b.pack(expand=True, fill='both') |
| 240 | self.assertEqual(b.winfo_reqwidth(), 16) |
| 241 | self.assertEqual(b.winfo_reqheight(), 16) |
| 242 | |
| 243 | def test_element_create_image_errors(self): |
| 244 | style = self.style |
nothing calls this directly
no test coverage detected