<s> from itertools import chain <EOL> import resource <EOL> from colors import * <EOL> class Theme ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _styles = { } <EOL> def set ( self , class_name , state , key , value ) : <EOL> """<STR_LIT>""" <EOL> self . _styles . setdefault ( class_name , { } ) . setdefault ( state , { } ) <EOL> self . _styles [ class_name ] [ state ] [ key ] = value <EOL> def get_dict_for_class ( self , class_name , state = None , base_name = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> classes = [ ] <EOL> klass = class_name <EOL> while True : <EOL> classes . append ( klass ) <EOL> if klass . __name__ == base_name : <EOL> break <EOL> klass = klass . __bases__ [ <NUM_LIT:0> ] <EOL> if state is None : <EOL> state = '<STR_LIT>' <EOL> style = { } <EOL> for klass in classes : <EOL> class_name = klass . __name__ <EOL> try : <EOL> state_styles = self . _styles [ class_name ] [ state ] <EOL> except KeyError : <EOL> state_styles = { } <EOL> if state != '<STR_LIT>' : <EOL> try : <EOL> normal_styles = self . _styles [ class_name ] [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> normal_styles = { } <EOL> state_styles = dict ( chain ( normal_styles . iteritems ( ) , <EOL> state_styles . iteritems ( ) ) ) <EOL> style = dict ( chain ( state_styles . iteritems ( ) , <EOL> style . iteritems ( ) ) ) <EOL> return style <EOL> def get_dict ( self , obj , state = None , base_name = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> return self . get_dict_for_class ( class_name = obj . __class__ , <EOL> state = obj . state , <EOL> base_name = base_name ) <EOL> def get_value ( self , class_name , attr , default_value = None , <EOL> state = '<STR_LIT>' , base_name = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> styles = self . get_dict_for_class ( class_name , state , base_name ) <EOL> try : <EOL> return styles [ attr ] <EOL> except KeyError : <EOL> return default_value <EOL> current = None <EOL> light_theme = Theme ( ) <EOL> dark_theme = Theme ( ) <EOL> def use_theme ( theme ) : <EOL> """<STR_LIT>""" <EOL> global current <EOL> current = theme <EOL> import scene <EOL> if scene . current is not None : <EOL> scene . current . stylize ( ) <EOL> def init_light_theme ( ) : <EOL> color1 = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> color2 = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> color3 = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> color4 = white_color <EOL> color5 = near_white_color <EOL> color6 = light_gray_color <EOL> color7 = gray_color <EOL> color8 = dark_gray_color <EOL> color9 = black_color <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color4 , color5 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:0> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = False ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color5 , color4 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color8 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color3 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color4 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = None ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = resource . get_font ( <NUM_LIT:16> ) ) <EOL> light_theme . label_height = <NUM_LIT:16> + <NUM_LIT:6> * <NUM_LIT:2> <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color4 , color6 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color1 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color8 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = resource . get_font ( <NUM_LIT:16> , use_bold = True ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> light_theme . button_height = <NUM_LIT:16> + <NUM_LIT:6> * <NUM_LIT:2> <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color4 , color6 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color1 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color4 , color6 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color5 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = whites_twin_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color5 , color4 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = clear_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = None ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = None ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = clear_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = clear_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = None ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color4 , color6 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = True ) <EOL> light_theme . shadow_size = <NUM_LIT> <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color7 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color4 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = None ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = clear_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = resource . get_font ( <NUM_LIT:16> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:6> , <NUM_LIT:6> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color3 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = clear_color ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color8 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = False ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = ( color1 , color2 ) ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT:1> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color9 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = True ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = <NUM_LIT> ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color4 ) <EOL> light_theme . set ( class_name = '<STR_LIT>' , <EOL> state = '<STR_LIT>' , <EOL> key = '<STR_LIT>' , <EOL> value = color6 ) <EOL> def init_dark_theme ( ) : <EOL> pass <EOL> def init ( ) : <EOL> """<STR_LIT>""" <EOL> init_light_theme ( ) <EOL> init_dark_theme ( ) <EOL> use_theme ( light_theme ) </s>
