<s> """<STR_LIT>""" <EOL> from PyQt4 import QtCore <EOL> from PyQt4 . QtGui import * <EOL> import sys <EOL> import traceback <EOL> from editor import Editor , HAVE_QSCI <EOL> presets = [ <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ( '<STR_LIT>' , '''<STR_LIT>''' ) , <EOL> ] <EOL> qsci_note = """<STR_LIT>""" <EOL> if not HAVE_QSCI : <EOL> presets [ <NUM_LIT:0> ] = ( presets [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , qsci_note + presets [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) <EOL> app = QApplication ( [ ] ) <EOL> win = QMainWindow ( ) <EOL> cw = QWidget ( ) <EOL> win . setCentralWidget ( cw ) <EOL> layout = QGridLayout ( ) <EOL> cw . setLayout ( layout ) <EOL> editor = Editor ( language = '<STR_LIT>' ) <EOL> vertex = Editor ( language = '<STR_LIT>' ) <EOL> fragment = Editor ( language = '<STR_LIT>' ) <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> editor . zoomOut ( ) <EOL> vertex . zoomOut ( ) <EOL> fragment . zoomOut ( ) <EOL> hsplit = QSplitter ( QtCore . Qt . Horizontal ) <EOL> vsplit = QSplitter ( QtCore . Qt . Vertical ) <EOL> layout . addWidget ( hsplit ) <EOL> hsplit . addWidget ( editor ) <EOL> hsplit . addWidget ( vsplit ) <EOL> vsplit . addWidget ( vertex ) <EOL> vsplit . addWidget ( fragment ) <EOL> menubar = win . menuBar ( ) <EOL> last_loaded = - <NUM_LIT:1> <EOL> def load_example ( name ) : <EOL> global last_loaded <EOL> if isinstance ( name , int ) : <EOL> code = presets [ name ] [ <NUM_LIT:1> ] <EOL> editor . setText ( code ) <EOL> last_loaded = name <EOL> else : <EOL> for i , preset in enumerate ( presets ) : <EOL> n , code = preset <EOL> if n == name : <EOL> editor . setText ( code ) <EOL> last_loaded = i <EOL> return <EOL> def load_next ( ) : <EOL> global last_loaded <EOL> try : <EOL> load_example ( last_loaded + <NUM_LIT:1> ) <EOL> except IndexError : <EOL> pass <EOL> def mk_load_callback ( name ) : <EOL> return lambda : load_example ( name ) <EOL> example_menu = menubar . addMenu ( '<STR_LIT>' ) <EOL> for i , preset in enumerate ( presets ) : <EOL> name = preset [ <NUM_LIT:0> ] <EOL> action = example_menu . addAction ( "<STR_LIT>" % ( i , name ) , <EOL> mk_load_callback ( name ) ) <EOL> next_action = menubar . addAction ( "<STR_LIT>" , load_next ) <EOL> win . show ( ) <EOL> win . resize ( <NUM_LIT> , <NUM_LIT> ) <EOL> hsplit . setSizes ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> load_example ( <NUM_LIT:0> ) <EOL> def update ( ) : <EOL> code = editor . text ( ) <EOL> local = { } <EOL> glob = { } <EOL> try : <EOL> exec ( code , local , glob ) <EOL> vert = glob [ '<STR_LIT>' ] <EOL> frag = glob [ '<STR_LIT>' ] <EOL> editor . clear_marker ( ) <EOL> except Exception : <EOL> vert = traceback . format_exc ( ) <EOL> frag = "<STR_LIT>" <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> while tb is not None : <EOL> try : <EOL> if tb . tb_frame . f_code . co_filename == '<STR_LIT>' : <EOL> editor . set_marker ( tb . tb_lineno - <NUM_LIT:1> ) <EOL> except Exception : <EOL> pass <EOL> tb = tb . tb_next <EOL> vertex . setText ( vert ) <EOL> fragment . setText ( frag ) <EOL> editor . textChanged . connect ( update ) <EOL> update ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . exec_ ( ) </s>
