@@ -63,32 +63,30 @@ def set_drawing_area(self, da):
6363
6464 def get_color (self , rgb ):
6565 """
66- RGB is a unit RGB tuple, return a gtk.gdk.Color
66+ Take an RGB ( a unit RGB tuple) and return a allocated gtk.gdk.Color
6767 """
68+ try :
69+ return self ._cached [tuple (rgb )]
70+ except KeyError :
71+ if self ._cmap is None :
72+ raise RuntimeError ('First set the drawing area!' )
6873
69- try : return self ._cached [tuple (rgb )]
70- except KeyError : pass
71-
72- if self ._cmap is None :
73- raise RuntimeError ('First set the drawing area!' )
74-
75- #print 'rgb is', rgb
76- r ,g ,b = rgb
77- color = self ._cmap .alloc_color (int (r * 65025 ),int (g * 65025 ),int (b * 65025 ))
78- self ._cached [tuple (rgb )] = color
79- return color
74+ r ,g ,b = rgb
75+ color = self ._cmap .alloc_color (
76+ int (r * 65025 ),int (g * 65025 ),int (b * 65025 ))
77+ self ._cached [tuple (rgb )] = color
78+ return color
8079
8180 def get_rgb (self , color ):
8281 """
83- RGB is a unit RGB tuple, return a gtk.gdk.Color
82+ Take a gtk.gdk.Color and return an RGB (a unit RGB tuple)
8483 """
85-
8684 return [val / 65535 for val in (color .red , color .green , color .blue )]
8785
8886colorManager = ColorManagerGTK ()
8987
90- class RendererGTK (RendererBase ):
9188
89+ class RendererGTK (RendererBase ):
9290 fontweights = {
9391 100 : pango .WEIGHT_ULTRALIGHT ,
9492 200 : pango .WEIGHT_LIGHT ,
0 commit comments