<s> """<STR_LIT>""" <EOL> import sys <EOL> import Tkinter <EOL> def runningAsOSXApp ( ) : <EOL> """<STR_LIT>""" <EOL> return ( sys . platform == '<STR_LIT>' and '<STR_LIT>' in sys . argv [ <NUM_LIT:0> ] ) <EOL> def addOpenEventSupport ( root , flist ) : <EOL> """<STR_LIT>""" <EOL> def doOpenFile ( * args ) : <EOL> for fn in args : <EOL> flist . open ( fn ) <EOL> root . createcommand ( "<STR_LIT>" , doOpenFile ) <EOL> def hideTkConsole ( root ) : <EOL> try : <EOL> root . tk . call ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> except Tkinter . TclError : <EOL> pass <EOL> def overrideRootMenu ( root , flist ) : <EOL> """<STR_LIT>""" <EOL> from Tkinter import Menu , Text , Text <EOL> from EditorWindow import prepstr , get_accelerator <EOL> import Bindings <EOL> import WindowList <EOL> from MultiCall import MultiCallCreator <EOL> menubar = Menu ( root ) <EOL> root . configure ( menu = menubar ) <EOL> menudict = { } <EOL> menudict [ '<STR_LIT>' ] = menu = Menu ( menubar , name = '<STR_LIT>' ) <EOL> menubar . add_cascade ( label = '<STR_LIT>' , menu = menu , underline = <NUM_LIT:0> ) <EOL> def postwindowsmenu ( menu = menu ) : <EOL> end = menu . index ( '<STR_LIT:end>' ) <EOL> if end is None : <EOL> end = - <NUM_LIT:1> <EOL> if end > <NUM_LIT:0> : <EOL> menu . delete ( <NUM_LIT:0> , end ) <EOL> WindowList . add_windows_to_menu ( menu ) <EOL> WindowList . register_callback ( postwindowsmenu ) <EOL> menudict [ '<STR_LIT>' ] = menu = Menu ( menubar , name = '<STR_LIT>' ) <EOL> menubar . add_cascade ( label = '<STR_LIT>' , menu = menu ) <EOL> def about_dialog ( event = None ) : <EOL> import aboutDialog <EOL> aboutDialog . AboutDialog ( root , '<STR_LIT>' ) <EOL> def config_dialog ( event = None ) : <EOL> import configDialog <EOL> configDialog . ConfigDialog ( root , '<STR_LIT>' ) <EOL> root . bind ( '<STR_LIT>' , about_dialog ) <EOL> root . bind ( '<STR_LIT>' , config_dialog ) <EOL> if flist : <EOL> root . bind ( '<STR_LIT>' , flist . close_all_callback ) <EOL> tkversion = root . tk . eval ( '<STR_LIT>' ) <EOL> if tkversion >= '<STR_LIT>' : <EOL> Bindings . menudefs [ <NUM_LIT:0> ] = ( '<STR_LIT>' , [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> None , <EOL> ] ) <EOL> root . createcommand ( '<STR_LIT>' , config_dialog ) <EOL> else : <EOL> for mname , entrylist in Bindings . menudefs : <EOL> menu = menudict . get ( mname ) <EOL> if not menu : <EOL> continue <EOL> else : <EOL> for entry in entrylist : <EOL> if not entry : <EOL> menu . add_separator ( ) <EOL> else : <EOL> label , eventname = entry <EOL> underline , label = prepstr ( label ) <EOL> accelerator = get_accelerator ( Bindings . default_keydefs , <EOL> eventname ) <EOL> def command ( text = root , eventname = eventname ) : <EOL> text . event_generate ( eventname ) <EOL> menu . add_command ( label = label , underline = underline , <EOL> command = command , accelerator = accelerator ) <EOL> def setupApp ( root , flist ) : <EOL> """<STR_LIT>""" <EOL> if not runningAsOSXApp ( ) : return <EOL> hideTkConsole ( root ) <EOL> overrideRootMenu ( root , flist ) <EOL> addOpenEventSupport ( root , flist ) </s>
