<s> """<STR_LIT>""" <EOL> from Tkinter import * <EOL> import ColorDB <EOL> ADDTOVIEW = '<STR_LIT>' <EOL> class TextViewer : <EOL> def __init__ ( self , switchboard , master = None ) : <EOL> self . __sb = switchboard <EOL> optiondb = switchboard . optiondb ( ) <EOL> root = self . __root = Toplevel ( master , class_ = '<STR_LIT>' ) <EOL> root . protocol ( '<STR_LIT>' , self . withdraw ) <EOL> root . title ( '<STR_LIT>' ) <EOL> root . iconname ( '<STR_LIT>' ) <EOL> root . bind ( '<STR_LIT>' , self . __quit ) <EOL> root . bind ( '<STR_LIT>' , self . __quit ) <EOL> root . bind ( '<STR_LIT>' , self . withdraw ) <EOL> root . bind ( '<STR_LIT>' , self . withdraw ) <EOL> self . __text = Text ( root , relief = SUNKEN , <EOL> background = optiondb . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> foreground = optiondb . get ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> width = <NUM_LIT> , height = <NUM_LIT:15> ) <EOL> sfg = optiondb . get ( '<STR_LIT>' ) <EOL> if sfg : <EOL> self . __text . configure ( selectforeground = sfg ) <EOL> sbg = optiondb . get ( '<STR_LIT>' ) <EOL> if sbg : <EOL> self . __text . configure ( selectbackground = sbg ) <EOL> ibg = optiondb . get ( '<STR_LIT>' ) <EOL> if ibg : <EOL> self . __text . configure ( insertbackground = ibg ) <EOL> self . __text . pack ( ) <EOL> self . __text . insert ( <NUM_LIT:0.0> , optiondb . get ( '<STR_LIT>' , '''<STR_LIT>''' ) ) <EOL> insert = optiondb . get ( '<STR_LIT>' ) <EOL> if insert : <EOL> self . __text . mark_set ( INSERT , insert ) <EOL> try : <EOL> start , end = optiondb . get ( '<STR_LIT>' , ( <NUM_LIT> , END ) ) <EOL> self . __text . tag_add ( SEL , start , end ) <EOL> except ValueError : <EOL> pass <EOL> self . __text . focus_set ( ) <EOL> self . __trackp = BooleanVar ( ) <EOL> self . __trackp . set ( optiondb . get ( '<STR_LIT>' , <NUM_LIT:0> ) ) <EOL> self . __which = IntVar ( ) <EOL> self . __which . set ( optiondb . get ( '<STR_LIT>' , <NUM_LIT:0> ) ) <EOL> self . __t = Checkbutton ( root , text = '<STR_LIT>' , <EOL> variable = self . __trackp , <EOL> relief = GROOVE , <EOL> command = self . __toggletrack ) <EOL> self . __t . pack ( fill = X , expand = YES ) <EOL> frame = self . __frame = Frame ( root ) <EOL> frame . pack ( ) <EOL> self . __labels = [ ] <EOL> row = <NUM_LIT:2> <EOL> for text in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> l = Label ( frame , text = text ) <EOL> l . grid ( row = row , column = <NUM_LIT:0> , sticky = E ) <EOL> self . __labels . append ( l ) <EOL> row += <NUM_LIT:1> <EOL> col = <NUM_LIT:1> <EOL> for text in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> l = Label ( frame , text = text ) <EOL> l . grid ( row = <NUM_LIT:1> , column = col ) <EOL> self . __labels . append ( l ) <EOL> col += <NUM_LIT:1> <EOL> self . __radios = [ ] <EOL> for col in ( <NUM_LIT:1> , <NUM_LIT:2> ) : <EOL> for row in ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ) : <EOL> if row == <NUM_LIT:4> and col == <NUM_LIT:1> : <EOL> continue <EOL> r = Radiobutton ( frame , variable = self . __which , <EOL> value = ( row - <NUM_LIT:2> ) * <NUM_LIT:2> + col - <NUM_LIT:1> , <EOL> command = self . __set_color ) <EOL> r . grid ( row = row , column = col ) <EOL> self . __radios . append ( r ) <EOL> self . __toggletrack ( ) <EOL> def __quit ( self , event = None ) : <EOL> self . __root . quit ( ) <EOL> def withdraw ( self , event = None ) : <EOL> self . __root . withdraw ( ) <EOL> def deiconify ( self , event = None ) : <EOL> self . __root . deiconify ( ) <EOL> def __forceupdate ( self , event = None ) : <EOL> self . __sb . update_views_current ( ) <EOL> def __toggletrack ( self , event = None ) : <EOL> if self . __trackp . get ( ) : <EOL> state = NORMAL <EOL> fg = self . __radios [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> else : <EOL> state = DISABLED <EOL> fg = self . __radios [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> for r in self . __radios : <EOL> r . configure ( state = state ) <EOL> for l in self . __labels : <EOL> l . configure ( foreground = fg ) <EOL> def __set_color ( self , event = None ) : <EOL> which = self . __which . get ( ) <EOL> text = self . __text <EOL> if which == <NUM_LIT:0> : <EOL> color = text [ '<STR_LIT>' ] <EOL> elif which == <NUM_LIT:1> : <EOL> color = text [ '<STR_LIT>' ] <EOL> elif which == <NUM_LIT:2> : <EOL> color = text [ '<STR_LIT>' ] <EOL> elif which == <NUM_LIT:3> : <EOL> color = text [ '<STR_LIT>' ] <EOL> elif which == <NUM_LIT:5> : <EOL> color = text [ '<STR_LIT>' ] <EOL> try : <EOL> red , green , blue = ColorDB . rrggbb_to_triplet ( color ) <EOL> except ColorDB . BadColor : <EOL> red , green , blue = self . __sb . colordb ( ) . find_byname ( color ) <EOL> self . __sb . update_views ( red , green , blue ) <EOL> def update_yourself ( self , red , green , blue ) : <EOL> if self . __trackp . get ( ) : <EOL> colorname = ColorDB . triplet_to_rrggbb ( ( red , green , blue ) ) <EOL> which = self . __which . get ( ) <EOL> text = self . __text <EOL> if which == <NUM_LIT:0> : <EOL> text . configure ( foreground = colorname ) <EOL> elif which == <NUM_LIT:1> : <EOL> text . configure ( background = colorname ) <EOL> elif which == <NUM_LIT:2> : <EOL> text . configure ( selectforeground = colorname ) <EOL> elif which == <NUM_LIT:3> : <EOL> text . configure ( selectbackground = colorname ) <EOL> elif which == <NUM_LIT:5> : <EOL> text . configure ( insertbackground = colorname ) <EOL> def save_options ( self , optiondb ) : <EOL> optiondb [ '<STR_LIT>' ] = self . __trackp . get ( ) <EOL> optiondb [ '<STR_LIT>' ] = self . __which . get ( ) <EOL> optiondb [ '<STR_LIT>' ] = self . __text . get ( <NUM_LIT:0.0> , '<STR_LIT>' ) <EOL> optiondb [ '<STR_LIT>' ] = self . __text . tag_ranges ( SEL ) [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> optiondb [ '<STR_LIT>' ] = self . __text . index ( INSERT ) <EOL> optiondb [ '<STR_LIT>' ] = self . __text [ '<STR_LIT>' ] <EOL> optiondb [ '<STR_LIT>' ] = self . __text [ '<STR_LIT>' ] <EOL> optiondb [ '<STR_LIT>' ] = self . __text [ '<STR_LIT>' ] <EOL> optiondb [ '<STR_LIT>' ] = self . __text [ '<STR_LIT>' ] <EOL> optiondb [ '<STR_LIT>' ] = self . __text [ '<STR_LIT>' ] </s>
