class SPOTDigitizer(TFrame): def __init__(self, parent, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) spot_frame = TFrame(self, borderwidth=2, style='FlatFrame') spot_frame.pack(side=TOP) label = TLabel(spot_frame, text=_('Color name:'), justify=LEFT) label.pack(side=TOP) self.colorname_value = StringVar('') self.colorname = TEntrybox(spot_frame, text='', width=25, textvariable=self.colorname_value) self.colorname.set_state('readonly') self.colorname.pack(side=BOTTOM, fill=X) cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame') cmyk_frame.pack(side=TOP) self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT) self.CMYK_label.pack(side=LEFT, padx=10) self.RGB_label = TLabel(cmyk_frame, text='R:\nG:\nB:', justify=LEFT) self.RGB_label.pack(side=LEFT, padx=10) self.HTML_label = TLabel(self, text='HTML:', justify=LEFT) self.HTML_label.pack(side=BOTTOM, pady=5) def set_color(self, color): self.color = color c, m, y, k = color.getCMYK() self.CMYK_label['text'] = 'C: %d\nM: %d\nY: %d\nK: %d' % (round( c * 100, 2), round(m * 100, 2), round(y * 100, 2), round( k * 100, 2)) r, g, b = color.getRGB() text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round( g * 255, 2), round(b * 255, 2)) self.RGB_label['text'] = text int_color = (round(r * 255), round(g * 255), round(b * 255)) text = 'HTML: #%02X%02X%02X' % int_color self.HTML_label['text'] = text if color.name == 'All': self.colorname_value.set(color.toString()) else: self.colorname_value.set(color.name)
class SPOTDigitizer(TFrame): def __init__(self, parent, **kw): TFrame.__init__(self, parent, style='FlatFrame', **kw) spot_frame = TFrame(self, borderwidth=2, style='FlatFrame') spot_frame.pack(side=TOP) label = TLabel(spot_frame, text=_('Color name:'), justify=LEFT) label.pack(side=TOP) self.colorname_value = StringVar('') self.colorname = TEntrybox(spot_frame, text='', width=25, textvariable=self.colorname_value) self.colorname.set_state('readonly') self.colorname.pack(side=BOTTOM, fill=X) cmyk_frame = TFrame(self, borderwidth=2, style='FlatFrame') cmyk_frame.pack(side=TOP) self.CMYK_label = TLabel(cmyk_frame, text='C:\nM:\nY:\nK:', justify=LEFT) self.CMYK_label.pack(side=LEFT, padx=10) self.RGB_label = TLabel(cmyk_frame, text='R:\nG:\nB:', justify=LEFT) self.RGB_label.pack(side=LEFT, padx=10) self.HTML_label = TLabel(self, text='HTML:', justify=LEFT) self.HTML_label.pack(side=BOTTOM, pady=5) def set_color(self, color): self.color = color c, m, y, k = color.getCMYK() self.CMYK_label['text'] = 'C: %d\nM: %d\nY: %d\nK: %d' % (round(c * 100, 2), round(m * 100, 2), round(y * 100, 2), round(k * 100, 2)) r, g, b = color.getRGB() text = 'R: %d\nG: %d\nB: %d' % (round(r * 255, 2), round(g * 255, 2), round(b * 255, 2)) self.RGB_label['text'] = text int_color = (round(r * 255), round(g * 255), round(b * 255)) text = 'HTML: #%02X%02X%02X' % int_color self.HTML_label['text'] = text if color.name == 'All': self.colorname_value.set(color.toString()) else: self.colorname_value.set(color.name)