Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
tkinter.test.test_ttk.test_style.StyleTest Class Reference

List of all members.

Public Member Functions

def setUp
def test_configure
def test_map
def test_lookup
def test_layout
def test_theme_use

Public Attributes

 style

Detailed Description

Definition at line 10 of file test_style.py.


Member Function Documentation

Definition at line 12 of file test_style.py.

00012 
00013     def setUp(self):
00014         self.style = ttk.Style()
00015 

Here is the caller graph for this function:

Definition at line 16 of file test_style.py.

00016 
00017     def test_configure(self):
00018         style = self.style
00019         style.configure('TButton', background='yellow')
00020         self.assertEqual(style.configure('TButton', 'background'),
00021             'yellow')
00022         self.assertTrue(isinstance(style.configure('TButton'), dict))
00023 

Here is the call graph for this function:

Definition at line 44 of file test_style.py.

00044 
00045     def test_layout(self):
00046         style = self.style
00047         self.assertRaises(tkinter.TclError, style.layout, 'NotALayout')
00048         tv_style = style.layout('Treeview')
00049 
00050         # "erase" Treeview layout
00051         style.layout('Treeview', '')
00052         self.assertEqual(style.layout('Treeview'),
00053             [('null', {'sticky': 'nswe'})]
00054         )
00055 
00056         # restore layout
00057         style.layout('Treeview', tv_style)
00058         self.assertEqual(style.layout('Treeview'), tv_style)
00059 
00060         # should return a list
00061         self.assertTrue(isinstance(style.layout('TButton'), list))
00062 
00063         # correct layout, but "option" doesn't exist as option
00064         self.assertRaises(tkinter.TclError, style.layout, 'Treeview',
00065             [('name', {'option': 'inexistent'})])
00066 

Here is the call graph for this function:

Definition at line 32 of file test_style.py.

00032 
00033     def test_lookup(self):
00034         style = self.style
00035         style.configure('TButton', background='yellow')
00036         style.map('TButton', background=[('active', 'background', 'blue')])
00037 
00038         self.assertEqual(style.lookup('TButton', 'background'), 'yellow')
00039         self.assertEqual(style.lookup('TButton', 'background',
00040             ['active', 'background']), 'blue')
00041         self.assertEqual(style.lookup('TButton', 'optionnotdefined',
00042             default='iknewit'), 'iknewit')
00043 

Here is the call graph for this function:

Definition at line 24 of file test_style.py.

00024 
00025     def test_map(self):
00026         style = self.style
00027         style.map('TButton', background=[('active', 'background', 'blue')])
00028         self.assertEqual(style.map('TButton', 'background'),
00029             [('active', 'background', 'blue')])
00030         self.assertTrue(isinstance(style.map('TButton'), dict))
00031 

Here is the call graph for this function:

Definition at line 67 of file test_style.py.

00067 
00068     def test_theme_use(self):
00069         self.assertRaises(tkinter.TclError, self.style.theme_use,
00070             'nonexistingname')
00071 
00072         curr_theme = self.style.theme_use()
00073         new_theme = None
00074         for theme in self.style.theme_names():
00075             if theme != curr_theme:
00076                 new_theme = theme
00077                 self.style.theme_use(theme)
00078                 break
00079         else:
00080             # just one theme available, can't go on with tests
00081             return
00082 
00083         self.assertFalse(curr_theme == new_theme)
00084         self.assertFalse(new_theme != self.style.theme_use())
00085 
00086         self.style.theme_use(curr_theme)
00087 

Here is the call graph for this function:


Member Data Documentation

Definition at line 13 of file test_style.py.


The documentation for this class was generated from the following file: