<s> '''<STR_LIT>''' <EOL> from kivy . app import App <EOL> from kivy . uix . gridlayout import GridLayout <EOL> from kivy . uix . gesturesurface import GestureSurface <EOL> from kivy . uix . screenmanager import ScreenManager , Screen , SlideTransition <EOL> from kivy . uix . label import Label <EOL> from kivy . multistroke import Recognizer <EOL> from historymanager import GestureHistoryManager <EOL> from gesturedatabase import GestureDatabase <EOL> from settings import MultistrokeSettingsContainer <EOL> class MainMenu ( GridLayout ) : <EOL> pass <EOL> class MultistrokeAppSettings ( MultistrokeSettingsContainer ) : <EOL> pass <EOL> class MultistrokeApp ( App ) : <EOL> def goto_database_screen ( self , * l ) : <EOL> self . database . import_gdb ( ) <EOL> self . manager . current = '<STR_LIT>' <EOL> def handle_gesture_cleanup ( self , surface , g , * l ) : <EOL> if hasattr ( g , '<STR_LIT>' ) : <EOL> surface . remove_widget ( g . _result_label ) <EOL> def handle_gesture_discard ( self , surface , g , * l ) : <EOL> if surface . draw_timeout == <NUM_LIT:0> : <EOL> return <EOL> text = '<STR_LIT>' <EOL> g . _result_label = Label ( text = text , markup = True , size_hint = ( None , None ) , <EOL> center = ( g . bbox [ '<STR_LIT>' ] , g . bbox [ '<STR_LIT>' ] ) ) <EOL> self . surface . add_widget ( g . _result_label ) <EOL> def handle_gesture_complete ( self , surface , g , * l ) : <EOL> result = self . recognizer . recognize ( g . get_vectors ( ) ) <EOL> result . _gesture_obj = g <EOL> result . bind ( on_complete = self . handle_recognize_complete ) <EOL> def handle_recognize_complete ( self , result , * l ) : <EOL> self . history . add_recognizer_result ( result ) <EOL> if self . surface . draw_timeout == <NUM_LIT:0> : <EOL> return <EOL> best = result . best <EOL> if best [ '<STR_LIT:name>' ] is None : <EOL> text = '<STR_LIT>' <EOL> else : <EOL> text = '<STR_LIT>' % ( <EOL> best [ '<STR_LIT:name>' ] , best [ '<STR_LIT>' ] , best [ '<STR_LIT>' ] ) <EOL> g = result . _gesture_obj <EOL> g . _result_label = Label ( text = text , markup = True , size_hint = ( None , None ) , <EOL> center = ( g . bbox [ '<STR_LIT>' ] , g . bbox [ '<STR_LIT>' ] ) ) <EOL> self . surface . add_widget ( g . _result_label ) <EOL> def build ( self ) : <EOL> self . manager = ScreenManager ( transition = SlideTransition ( <EOL> duration = <NUM_LIT> ) ) <EOL> self . recognizer = Recognizer ( ) <EOL> surface = GestureSurface ( line_width = <NUM_LIT:2> , draw_bbox = True , <EOL> use_random_color = True ) <EOL> surface_screen = Screen ( name = '<STR_LIT>' ) <EOL> surface_screen . add_widget ( surface ) <EOL> self . manager . add_widget ( surface_screen ) <EOL> surface . bind ( on_gesture_discard = self . handle_gesture_discard ) <EOL> surface . bind ( on_gesture_complete = self . handle_gesture_complete ) <EOL> surface . bind ( on_gesture_cleanup = self . handle_gesture_cleanup ) <EOL> self . surface = surface <EOL> history = GestureHistoryManager ( ) <EOL> history_screen = Screen ( name = '<STR_LIT>' ) <EOL> history_screen . add_widget ( history ) <EOL> self . history = history <EOL> self . manager . add_widget ( history_screen ) <EOL> database = GestureDatabase ( recognizer = self . recognizer ) <EOL> database_screen = Screen ( name = '<STR_LIT>' ) <EOL> database_screen . add_widget ( database ) <EOL> self . database = database <EOL> self . manager . add_widget ( database_screen ) <EOL> app_settings = MultistrokeAppSettings ( ) <EOL> ids = app_settings . ids <EOL> ids . max_strokes . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> ids . temporal_win . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> ids . timeout . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> ids . line_width . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> ids . draw_bbox . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> ids . use_random_color . bind ( value = surface . setter ( '<STR_LIT>' ) ) <EOL> settings_screen = Screen ( name = '<STR_LIT>' ) <EOL> settings_screen . add_widget ( app_settings ) <EOL> self . manager . add_widget ( settings_screen ) <EOL> layout = GridLayout ( cols = <NUM_LIT:1> ) <EOL> layout . add_widget ( self . manager ) <EOL> layout . add_widget ( MainMenu ( ) ) <EOL> return layout <EOL> if __name__ in ( '<STR_LIT:__main__>' , '<STR_LIT>' ) : <EOL> MultistrokeApp ( ) . run ( ) </s>
