Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
tkinter.test.test_ttk.test_widgets.WidgetTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_identify
def test_widget_state

Public Attributes

 widget

Detailed Description

Tests methods available in every ttk widget.

Definition at line 13 of file test_widgets.py.


Member Function Documentation

Definition at line 16 of file test_widgets.py.

00016 
00017     def setUp(self):
00018         support.root_deiconify()
00019         self.widget = ttk.Button(width=0, text="Text")
00020         self.widget.pack()
00021         self.widget.wait_visibility()

Here is the caller graph for this function:

Definition at line 22 of file test_widgets.py.

00022 
00023     def tearDown(self):
00024         self.widget.destroy()
00025         support.root_withdraw()
00026 

Here is the caller graph for this function:

Definition at line 27 of file test_widgets.py.

00027 
00028     def test_identify(self):
00029         self.widget.update_idletasks()
00030         self.assertEqual(self.widget.identify(
00031             int(self.widget.winfo_width() / 2),
00032             int(self.widget.winfo_height() / 2)
00033             ), "label")
00034         self.assertEqual(self.widget.identify(-1, -1), "")
00035 
00036         self.assertRaises(tkinter.TclError, self.widget.identify, None, 5)
00037         self.assertRaises(tkinter.TclError, self.widget.identify, 5, None)
00038         self.assertRaises(tkinter.TclError, self.widget.identify, 5, '')
00039 

Here is the call graph for this function:

Definition at line 40 of file test_widgets.py.

00040 
00041     def test_widget_state(self):
00042         # XXX not sure about the portability of all these tests
00043         self.assertEqual(self.widget.state(), ())
00044         self.assertEqual(self.widget.instate(['!disabled']), True)
00045 
00046         # changing from !disabled to disabled
00047         self.assertEqual(self.widget.state(['disabled']), ('!disabled', ))
00048         # no state change
00049         self.assertEqual(self.widget.state(['disabled']), ())
00050         # change back to !disable but also active
00051         self.assertEqual(self.widget.state(['!disabled', 'active']),
00052             ('!active', 'disabled'))
00053         # no state changes, again
00054         self.assertEqual(self.widget.state(['!disabled', 'active']), ())
00055         self.assertEqual(self.widget.state(['active', '!disabled']), ())
00056 
00057         def test_cb(arg1, **kw):
00058             return arg1, kw
00059         self.assertEqual(self.widget.instate(['!disabled'],
00060             test_cb, "hi", **{"msg": "there"}),
00061             ('hi', {'msg': 'there'}))
00062 
00063         # attempt to set invalid statespec
00064         currstate = self.widget.state()
00065         self.assertRaises(tkinter.TclError, self.widget.instate,
00066             ['badstate'])
00067         self.assertRaises(tkinter.TclError, self.widget.instate,
00068             ['disabled', 'badstate'])
00069         # verify that widget didn't change its state
00070         self.assertEqual(currstate, self.widget.state())
00071 
00072         # ensuring that passing None as state doesn't modify current state
00073         self.widget.state(['active', '!disabled'])
00074         self.assertEqual(self.widget.state(), ('active', ))
00075 

Here is the call graph for this function:


Member Data Documentation

Definition at line 18 of file test_widgets.py.


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