Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_virtual_event
def test_postcommand
def test_values

Public Attributes

 combo

Private Member Functions

def _show_drop_down_listbox

Detailed Description

Definition at line 114 of file test_widgets.py.


Member Function Documentation

Definition at line 124 of file test_widgets.py.

00124 
00125     def _show_drop_down_listbox(self):
00126         width = self.combo.winfo_width()
00127         self.combo.event_generate('<ButtonPress-1>', x=width - 5, y=5)
00128         self.combo.event_generate('<ButtonRelease-1>', x=width - 5, y=5)
00129         self.combo.update_idletasks()
00130 

Here is the caller graph for this function:

Definition at line 116 of file test_widgets.py.

00116 
00117     def setUp(self):
00118         support.root_deiconify()
00119         self.combo = ttk.Combobox()

Here is the caller graph for this function:

Definition at line 120 of file test_widgets.py.

00120 
00121     def tearDown(self):
00122         self.combo.destroy()
00123         support.root_withdraw()

Here is the caller graph for this function:

Definition at line 149 of file test_widgets.py.

00149 
00150     def test_postcommand(self):
00151         success = []
00152 
00153         self.combo['postcommand'] = lambda: success.append(True)
00154         self.combo.pack()
00155         self.combo.wait_visibility()
00156 
00157         self._show_drop_down_listbox()
00158         self.assertTrue(success)
00159 
00160         # testing postcommand removal
00161         self.combo['postcommand'] = ''
00162         self._show_drop_down_listbox()
00163         self.assertEqual(len(success), 1)
00164 

Here is the call graph for this function:

Definition at line 165 of file test_widgets.py.

00165 
00166     def test_values(self):
00167         def check_get_current(getval, currval):
00168             self.assertEqual(self.combo.get(), getval)
00169             self.assertEqual(self.combo.current(), currval)
00170 
00171         check_get_current('', -1)
00172 
00173         self.combo['values'] = ['a', 1, 'c']
00174 
00175         self.combo.set('c')
00176         check_get_current('c', 2)
00177 
00178         self.combo.current(0)
00179         check_get_current('a', 0)
00180 
00181         self.combo.set('d')
00182         check_get_current('d', -1)
00183 
00184         # testing values with empty string
00185         self.combo.set('')
00186         self.combo['values'] = (1, 2, '', 3)
00187         check_get_current('', 2)
00188 
00189         # testing values with empty string set through configure
00190         self.combo.configure(values=[1, '', 2])
00191         self.assertEqual(self.combo['values'], ('1', '', '2'))
00192 
00193         # out of range
00194         self.assertRaises(tkinter.TclError, self.combo.current,
00195             len(self.combo['values']))
00196         # it expects an integer (or something that can be converted to int)
00197         self.assertRaises(tkinter.TclError, self.combo.current, '')
00198 
00199         # testing creating combobox with empty string in values
00200         combo2 = ttk.Combobox(values=[1, 2, ''])
00201         self.assertEqual(combo2['values'], ('1', '2', ''))
00202         combo2.destroy()
00203 

Here is the call graph for this function:

Definition at line 131 of file test_widgets.py.

00131 
00132     def test_virtual_event(self):
00133         success = []
00134 
00135         self.combo['values'] = [1]
00136         self.combo.bind('<<ComboboxSelected>>',
00137             lambda evt: success.append(True))
00138         self.combo.pack()
00139         self.combo.wait_visibility()
00140 
00141         height = self.combo.winfo_height()
00142         self._show_drop_down_listbox()
00143         self.combo.update()
00144         self.combo.event_generate('<Return>')
00145         self.combo.update()
00146 
00147         self.assertTrue(success)
00148 

Here is the call graph for this function:


Member Data Documentation

Definition at line 118 of file test_widgets.py.


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