class ColorConverterTest(unittest.TestCase): def setUp(self): self._converter = ColorConverter() def test_convert_to_gdk_color_should_create_gdk_color_with_equivalent_rgb_values(self): color = Color(0xaaff33) gdk_color = self._converter.convert_to_gdk_color(color) self.assertEquals(0x3333, gdk_color.blue) self.assertEquals(0xffff, gdk_color.green) self.assertEquals(0xaaaa, gdk_color.red) def test_convert_to_color_should_create_color_with_equivalent_rgb_values(self): gdk_col = gtk.gdk.color_parse("#aaff33") color = self._converter.convert_to_color(gdk_col) self.assertEqual(0xaaff33, color.rgb_val)
class ColorConverterTest(unittest.TestCase): def setUp(self): self._converter = ColorConverter() def test_convert_to_gdk_color_should_create_gdk_color_with_equivalent_rgb_values( self): color = Color(0xaaff33) gdk_color = self._converter.convert_to_gdk_color(color) self.assertEqual(0x3333, gdk_color.blue) self.assertEqual(0xffff, gdk_color.green) self.assertEqual(0xaaaa, gdk_color.red) def test_convert_to_color_should_create_color_with_equivalent_rgb_values( self): gdk_col = Gdk.color_parse("#aaff33") color = self._converter.convert_to_color(gdk_col) self.assertEqual(0xaaff33, color.rgb_val)
def on_editcolor_clicked(self, widget): selected, iter = self.sportTreeView.get_selection().get_selected() if iter: sport_desc = selected.get_value(iter, 0) sport = self._sport_service.get_sport_by_name(sport_desc) colorseldlg = gtk.ColorSelectionDialog("test") colorseldlg.colorsel.set_has_palette(True) colorseldlg.colorsel.set_current_color( ColorConverter().convert_to_gdk_color(sport.color)) colorseldlg.run() gdk_color = colorseldlg.colorsel.get_current_color() self.stored_color = ColorConverter().convert_to_color(gdk_color) colorPixBuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 250, 20) colorPixBuf.fill(self.stored_color.rgba_val) self.newcolor.set_from_pixbuf(colorPixBuf) self.editcolor.set_from_pixbuf(colorPixBuf) colorseldlg.hide()
def setUp(self): self._converter = ColorConverter()