Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Private Attributes
pynche.ChipViewer.ChipViewer Class Reference

List of all members.

Public Member Functions

def __init__
def update_yourself

Private Member Functions

def __buttonpress
def __buttonrelease

Private Attributes

 __sb
 __frame
 __sframe
 __selected
 __nframe
 __nearest

Detailed Description

Definition at line 80 of file ChipViewer.py.


Constructor & Destructor Documentation

def pynche.ChipViewer.ChipViewer.__init__ (   self,
  switchboard,
  master = None 
)

Definition at line 81 of file ChipViewer.py.

00081 
00082     def __init__(self, switchboard, master=None):
00083         self.__sb = switchboard
00084         self.__frame = Frame(master, relief=RAISED, borderwidth=1)
00085         self.__frame.grid(row=3, column=0, ipadx=5, sticky='NSEW')
00086         # create the chip that will display the currently selected color
00087         # exactly
00088         self.__sframe = Frame(self.__frame)
00089         self.__sframe.grid(row=0, column=0)
00090         self.__selected = ChipWidget(self.__sframe, text='Selected')
00091         # create the chip that will display the nearest real X11 color
00092         # database color name
00093         self.__nframe = Frame(self.__frame)
00094         self.__nframe.grid(row=0, column=1)
00095         self.__nearest = ChipWidget(self.__nframe, text='Nearest',
00096                                     presscmd = self.__buttonpress,
00097                                     releasecmd = self.__buttonrelease)

Here is the caller graph for this function:


Member Function Documentation

def pynche.ChipViewer.ChipViewer.__buttonpress (   self,
  event = None 
) [private]

Definition at line 123 of file ChipViewer.py.

00123 
00124     def __buttonpress(self, event=None):
00125         self.__nearest.press()

def pynche.ChipViewer.ChipViewer.__buttonrelease (   self,
  event = None 
) [private]

Definition at line 126 of file ChipViewer.py.

00126 
00127     def __buttonrelease(self, event=None):
00128         self.__nearest.release()
00129         rrggbb = self.__nearest.get_color()
00130         red, green, blue = ColorDB.rrggbb_to_triplet(rrggbb)
00131         self.__sb.update_views(red, green, blue)
def pynche.ChipViewer.ChipViewer.update_yourself (   self,
  red,
  green,
  blue 
)

Definition at line 98 of file ChipViewer.py.

00098 
00099     def update_yourself(self, red, green, blue):
00100         # Selected always shows the #rrggbb name of the color, nearest always
00101         # shows the name of the nearest color in the database.  BAW: should
00102         # an exact match be indicated in some way?
00103         #
00104         # Always use the #rrggbb style to actually set the color, since we may
00105         # not be using X color names (e.g. "web-safe" names)
00106         colordb = self.__sb.colordb()
00107         rgbtuple = (red, green, blue)
00108         rrggbb = ColorDB.triplet_to_rrggbb(rgbtuple)
00109         # find the nearest
00110         nearest = colordb.nearest(red, green, blue)
00111         nearest_tuple = colordb.find_byname(nearest)
00112         nearest_rrggbb = ColorDB.triplet_to_rrggbb(nearest_tuple)
00113         self.__selected.set_color(rrggbb)
00114         self.__nearest.set_color(nearest_rrggbb)
00115         # set the name and messages areas
00116         self.__selected.set_name(rrggbb)
00117         if rrggbb == nearest_rrggbb:
00118             self.__selected.set_message(nearest)
00119         else:
00120             self.__selected.set_message('')
00121         self.__nearest.set_name(nearest_rrggbb)
00122         self.__nearest.set_message(nearest)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 83 of file ChipViewer.py.

Definition at line 94 of file ChipViewer.py.

Definition at line 92 of file ChipViewer.py.

Definition at line 82 of file ChipViewer.py.

Definition at line 89 of file ChipViewer.py.

Definition at line 87 of file ChipViewer.py.


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