Back to index

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

List of all members.

Public Member Functions

def setUp
def tearDown
def test_custom_event
def test_get
def test_set

Public Attributes

 scale

Detailed Description

Definition at line 458 of file test_widgets.py.


Member Function Documentation

Definition at line 460 of file test_widgets.py.

00460 
00461     def setUp(self):
00462         support.root_deiconify()
00463         self.scale = ttk.Scale()
00464         self.scale.pack()
00465         self.scale.update()

Here is the caller graph for this function:

Definition at line 466 of file test_widgets.py.

00466 
00467     def tearDown(self):
00468         self.scale.destroy()
00469         support.root_withdraw()
00470 

Here is the caller graph for this function:

Definition at line 471 of file test_widgets.py.

00471 
00472     def test_custom_event(self):
00473         failure = [1, 1, 1] # will need to be empty
00474 
00475         funcid = self.scale.bind('<<RangeChanged>>', lambda evt: failure.pop())
00476 
00477         self.scale['from'] = 10
00478         self.scale['from_'] = 10
00479         self.scale['to'] = 3
00480 
00481         self.assertFalse(failure)
00482 
00483         failure = [1, 1, 1]
00484         self.scale.configure(from_=2, to=5)
00485         self.scale.configure(from_=0, to=-2)
00486         self.scale.configure(to=10)
00487 
00488         self.assertFalse(failure)
00489 

Here is the call graph for this function:

Definition at line 490 of file test_widgets.py.

00490 
00491     def test_get(self):
00492         scale_width = self.scale.winfo_width()
00493         self.assertEqual(self.scale.get(scale_width, 0), self.scale['to'])
00494 
00495         self.assertEqual(self.scale.get(0, 0), self.scale['from'])
00496         self.assertEqual(self.scale.get(), self.scale['value'])
00497         self.scale['value'] = 30
00498         self.assertEqual(self.scale.get(), self.scale['value'])
00499 
00500         self.assertRaises(tkinter.TclError, self.scale.get, '', 0)
00501         self.assertRaises(tkinter.TclError, self.scale.get, 0, '')
00502 

Here is the call graph for this function:

Definition at line 503 of file test_widgets.py.

00503 
00504     def test_set(self):
00505         # set restricts the max/min values according to the current range
00506         max = self.scale['to']
00507         new_max = max + 10
00508         self.scale.set(new_max)
00509         self.assertEqual(self.scale.get(), max)
00510         min = self.scale['from']
00511         self.scale.set(min - 1)
00512         self.assertEqual(self.scale.get(), min)
00513 
00514         # changing directly the variable doesn't impose this limitation tho
00515         var = tkinter.DoubleVar()
00516         self.scale['variable'] = var
00517         var.set(max + 5)
00518         self.assertEqual(self.scale.get(), var.get())
00519         self.assertEqual(self.scale.get(), max + 5)
00520         del var
00521 
00522         # the same happens with the value option
00523         self.scale['value'] = max + 10
00524         self.assertEqual(self.scale.get(), max + 10)
00525         self.assertEqual(self.scale.get(), self.scale['value'])
00526 
00527         # nevertheless, note that the max/min values we can get specifying
00528         # x, y coords are the ones according to the current range
00529         self.assertEqual(self.scale.get(0, 0), min)
00530         self.assertEqual(self.scale.get(self.scale.winfo_width(), 0), max)
00531 
00532         self.assertRaises(tkinter.TclError, self.scale.set, None)
00533 

Here is the call graph for this function:


Member Data Documentation

Definition at line 462 of file test_widgets.py.


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