예제 #1
0
 def test_alphabar_init(self):
     ab = color.AlphaBar(self.window, alpha=200, color=(255, 255, 2),
                       height=12, width=200)
     ab.pack()
     self.window.update()
     ab.destroy()
     self.window.update()
     ab = color.AlphaBar(self.window, alpha=500, color=(255, 255, 2),
                       height=12, width=200)
     ab.pack()
     self.window.update()
     ab.destroy()
     self.window.update()
     ab = color.AlphaBar(self.window, alpha=-20, color=(255, 255, 2),
                       height=12, width=200)
     ab.pack()
     self.window.update()
     ab.destroy()
     self.window.update()
     var = tk.IntVar(self.window)
     ab = color.AlphaBar(self.window, alpha=200, color=(255, 255, 2),
                       height=12, width=200, variable=var)
     ab.pack()
     self.window.update()
     ab.destroy()
     self.window.update()
     var = tk.StringVar(self.window, 'a')
     ab = color.AlphaBar(self.window, alpha=200, color=(255, 255, 2),
                       height=12, width=200, variable=var)
     ab.pack()
     self.window.update()
예제 #2
0
 def test_alphabar_bindings(self):
     ab = color.AlphaBar(self.window, alpha=20, height=12, width=200)
     ab.pack()
     self.window.update()
     event = TestEvent(x=0, y=1)
     ab._on_click(event)
     self.window.update()
     self.assertEqual(ab.get(), 0)
     event.x = ab.winfo_width()
     ab._on_move(event)
     self.window.update()
     self.assertEqual(ab.get(), 255)
예제 #3
0
 def test_alphabar_functions(self):
     ab = color.AlphaBar(self.window, alpha=20, height=12, width=200)
     ab.pack()
     self.window.update()
     ab._draw_gradient(60, (255, 255, 0))
     self.window.update()
     self.assertEqual(ab.get(), 60)
     self.window.update()
     ab.set(40)
     self.window.update()
     self.assertEqual(ab.get(), 40)
     ab.set_color((0, 0, 0))
     self.window.update()
     ab.set_color((0, 0, 0, 100))
     self.window.update()
     ab._update_alpha()
     self.window.update()
     ab._variable.set(455)
     self.window.update()
     self.assertEqual(ab.get(), 255)
     ab._variable.set(-55)
     self.window.update()
     self.assertEqual(ab.get(), 0)