<s> import pygame <EOL> import view <EOL> import callback <EOL> import label <EOL> import theme <EOL> import focus <EOL> class Checkbox ( view . View ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , frame , text ) : <EOL> view . View . __init__ ( self , frame ) <EOL> self . checked = False <EOL> check_frame = pygame . Rect ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . check_label = label . Label ( check_frame , '<STR_LIT:U+0020>' ) <EOL> self . add_child ( self . check_label ) <EOL> self . label = label . Label ( pygame . Rect ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) , text ) <EOL> self . add_child ( self . label ) <EOL> self . on_checked = callback . Signal ( ) <EOL> self . on_unchecked = callback . Signal ( ) <EOL> def layout ( self ) : <EOL> self . check_label . frame . topleft = self . padding <EOL> check_size = theme . current . label_height - self . padding [ <NUM_LIT:1> ] * <NUM_LIT:2> <EOL> self . check_label . frame . w = check_size <EOL> self . check_label . frame . h = check_size <EOL> self . check_label . layout ( ) <EOL> self . label . shrink_wrap ( ) <EOL> margin = max ( self . check_label . margin [ <NUM_LIT:0> ] , self . label . margin [ <NUM_LIT:0> ] ) <EOL> self . label . frame . top = self . padding [ <NUM_LIT:1> ] <EOL> self . label . frame . left = self . check_label . frame . right + margin <EOL> self . label . frame . h = check_size <EOL> self . label . layout ( ) <EOL> self . frame . w = ( self . check_label . frame . w + margin + <EOL> self . label . frame . w + self . padding [ <NUM_LIT:0> ] * <NUM_LIT:2> ) <EOL> self . frame . h = theme . current . label_height <EOL> view . View . layout ( self ) <EOL> def mouse_up ( self , button , point ) : <EOL> view . View . mouse_up ( self , button , point ) <EOL> self . toggle ( ) <EOL> focus . set ( None ) <EOL> def toggle ( self , * args , ** kwargs ) : <EOL> self . checked = not self . checked <EOL> if self . checked : <EOL> self . check_label . text = '<STR_LIT:X>' <EOL> self . on_checked ( ) <EOL> else : <EOL> self . check_label . text = '<STR_LIT:U+0020>' <EOL> self . on_unchecked ( ) <EOL> def __repr__ ( self ) : <EOL> return self . label . text </s>
