<s> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT:..>" ) <EOL> import Tkinter as tk <EOL> import time <EOL> from async_gui . engine import Task , MultiProcessTask <EOL> from async_gui . toolkits . tk import TkEngine <EOL> from cpu_work import is_prime , PRIMES <EOL> engine = TkEngine ( ) <EOL> class Application ( tk . Frame ) : <EOL> def __init__ ( self , master = None ) : <EOL> tk . Frame . __init__ ( self , master , width = <NUM_LIT> , height = <NUM_LIT> ) <EOL> self . grid ( sticky = tk . N + tk . S + tk . W + tk . E ) <EOL> self . grid_propagate ( <NUM_LIT:0> ) <EOL> self . button = tk . Button ( self ) <EOL> self . button [ "<STR_LIT:text>" ] = "<STR_LIT>" <EOL> self . button [ "<STR_LIT>" ] = self . cpu_bound <EOL> self . button . grid ( column = <NUM_LIT:0> , row = <NUM_LIT:0> , sticky = tk . E + tk . W ) <EOL> header = tk . Label ( self ) <EOL> header [ "<STR_LIT:text>" ] = "<STR_LIT>" <EOL> header . grid ( column = <NUM_LIT:1> , row = <NUM_LIT:0> , sticky = tk . W ) <EOL> self . status = [ ] <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> self . status . append ( tk . Label ( self ) ) <EOL> self . status [ i ] . grid ( column = <NUM_LIT:1> , row = <NUM_LIT:1> + i , sticky = tk . W ) <EOL> @ engine . async <EOL> def cpu_bound ( self ) : <EOL> t = time . time ( ) <EOL> self . status [ <NUM_LIT:0> ] [ "<STR_LIT:text>" ] = "<STR_LIT>" <EOL> prime_flags = yield MultiProcessTask ( <EOL> [ Task ( is_prime , n ) for n in PRIMES ] <EOL> ) <EOL> print time . time ( ) - t <EOL> text = '<STR_LIT:\n>' . join ( "<STR_LIT>" % ( n , prime ) <EOL> for n , prime in zip ( PRIMES , prime_flags ) ) <EOL> self . status [ <NUM_LIT:0> ] [ "<STR_LIT:text>" ] = text <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> root = tk . Tk ( ) <EOL> engine . main_app = root <EOL> app = Application ( master = root ) <EOL> app . mainloop ( ) </s>
