<s> import os , sys <EOL> libcef_dll = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , <EOL> '<STR_LIT>' ) <EOL> if os . path . exists ( libcef_dll ) : <EOL> if ( <NUM_LIT:2> , <NUM_LIT:7> ) <= sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:8> ) : <EOL> import cefpython_py27 as cefpython <EOL> elif ( <NUM_LIT:3> , <NUM_LIT:4> ) <= sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:4> ) : <EOL> import cefpython_py34 as cefpython <EOL> else : <EOL> raise Exception ( "<STR_LIT>" % sys . version ) <EOL> else : <EOL> from cefpython3 import cefpython <EOL> import pygtk <EOL> pygtk . require ( '<STR_LIT>' ) <EOL> import gtk <EOL> import gobject <EOL> def GetApplicationPath ( file = None ) : <EOL> import re , os , platform <EOL> if not hasattr ( GetApplicationPath , "<STR_LIT>" ) : <EOL> if hasattr ( sys , "<STR_LIT>" ) : <EOL> dir = os . path . dirname ( sys . executable ) <EOL> elif "<STR_LIT>" in globals ( ) : <EOL> dir = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> else : <EOL> dir = os . getcwd ( ) <EOL> GetApplicationPath . dir = dir <EOL> if file is None : <EOL> file = "<STR_LIT>" <EOL> if not file . startswith ( "<STR_LIT:/>" ) and not file . startswith ( "<STR_LIT:\\>" ) and ( <EOL> not re . search ( r"<STR_LIT>" , file ) ) : <EOL> path = GetApplicationPath . dir + os . sep + file <EOL> if platform . system ( ) == "<STR_LIT>" : <EOL> path = re . sub ( r"<STR_LIT>" , re . escape ( os . sep ) , path ) <EOL> path = re . sub ( r"<STR_LIT>" , "<STR_LIT>" , path ) <EOL> return path <EOL> return str ( file ) <EOL> def ExceptHook ( excType , excValue , traceObject ) : <EOL> import traceback , os , time , codecs <EOL> errorMsg = "<STR_LIT:\n>" . join ( traceback . format_exception ( excType , excValue , <EOL> traceObject ) ) <EOL> errorFile = GetApplicationPath ( "<STR_LIT>" ) <EOL> try : <EOL> appEncoding = cefpython . g_applicationSettings [ "<STR_LIT>" ] <EOL> except : <EOL> appEncoding = "<STR_LIT:utf-8>" <EOL> if type ( errorMsg ) == bytes : <EOL> errorMsg = errorMsg . decode ( encoding = appEncoding , errors = "<STR_LIT:replace>" ) <EOL> try : <EOL> with codecs . open ( errorFile , mode = "<STR_LIT:a>" , encoding = appEncoding ) as fp : <EOL> fp . write ( "<STR_LIT>" % ( <EOL> time . strftime ( "<STR_LIT>" ) , errorMsg ) ) <EOL> except : <EOL> print ( "<STR_LIT>" % ( <EOL> errorFile ) ) <EOL> errorMsg = errorMsg . encode ( "<STR_LIT:ascii>" , errors = "<STR_LIT:replace>" ) <EOL> errorMsg = errorMsg . decode ( "<STR_LIT:ascii>" , errors = "<STR_LIT:replace>" ) <EOL> print ( "<STR_LIT:\n>" + errorMsg + "<STR_LIT:\n>" ) <EOL> cefpython . QuitMessageLoop ( ) <EOL> cefpython . Shutdown ( ) <EOL> os . _exit ( <NUM_LIT:1> ) <EOL> class PyGTKExample : <EOL> mainWindow = None <EOL> container = None <EOL> browser = None <EOL> exiting = None <EOL> searchEntry = None <EOL> def __init__ ( self ) : <EOL> gobject . timeout_add ( <NUM_LIT:10> , self . OnTimer ) <EOL> self . mainWindow = gtk . Window ( gtk . WINDOW_TOPLEVEL ) <EOL> self . mainWindow . connect ( '<STR_LIT>' , self . OnExit ) <EOL> self . mainWindow . set_size_request ( width = <NUM_LIT> , height = <NUM_LIT> ) <EOL> self . mainWindow . set_title ( '<STR_LIT>' ) <EOL> self . mainWindow . realize ( ) <EOL> self . container = gtk . DrawingArea ( ) <EOL> self . container . set_property ( '<STR_LIT>' , True ) <EOL> self . container . connect ( '<STR_LIT>' , self . OnSize ) <EOL> self . container . show ( ) <EOL> self . searchEntry = gtk . Entry ( ) <EOL> self . searchEntry . connect ( '<STR_LIT>' , self . OnWidgetClick ) <EOL> self . searchEntry . show ( ) <EOL> table = gtk . Table ( <NUM_LIT:3> , <NUM_LIT:1> , homogeneous = False ) <EOL> self . mainWindow . add ( table ) <EOL> table . attach ( self . CreateMenu ( ) , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> , yoptions = gtk . SHRINK ) <EOL> table . attach ( self . searchEntry , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , yoptions = gtk . SHRINK ) <EOL> table . attach ( self . container , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> table . show ( ) <EOL> windowID = self . container . get_window ( ) . handle <EOL> windowInfo = cefpython . WindowInfo ( ) <EOL> windowInfo . SetAsChild ( windowID ) <EOL> self . browser = cefpython . CreateBrowserSync ( windowInfo , <EOL> browserSettings = { } , <EOL> navigateUrl = GetApplicationPath ( '<STR_LIT>' ) ) <EOL> self . mainWindow . show ( ) <EOL> self . mainWindow . get_window ( ) . focus ( ) <EOL> self . searchEntry . grab_focus ( ) <EOL> def CreateMenu ( self ) : <EOL> file = gtk . MenuItem ( '<STR_LIT>' ) <EOL> file . show ( ) <EOL> filemenu = gtk . Menu ( ) <EOL> item = gtk . MenuItem ( '<STR_LIT>' ) <EOL> filemenu . append ( item ) <EOL> item . show ( ) <EOL> item = gtk . MenuItem ( '<STR_LIT>' ) <EOL> filemenu . append ( item ) <EOL> item . show ( ) <EOL> file . set_submenu ( filemenu ) <EOL> about = gtk . MenuItem ( '<STR_LIT>' ) <EOL> about . show ( ) <EOL> menubar = gtk . MenuBar ( ) <EOL> menubar . append ( file ) <EOL> menubar . append ( about ) <EOL> menubar . show ( ) <EOL> return menubar <EOL> def OnWidgetClick ( self , widget , data ) : <EOL> self . mainWindow . get_window ( ) . focus ( ) <EOL> def OnTimer ( self ) : <EOL> if self . exiting : <EOL> return False <EOL> cefpython . MessageLoopWork ( ) <EOL> return True <EOL> def OnFocusIn ( self , widget , data ) : <EOL> cefpython . WindowUtils . OnSetFocus ( self . container . get_window ( ) . handle , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> def OnSize ( self , widget , sizeAlloc ) : <EOL> cefpython . WindowUtils . OnSize ( self . container . get_window ( ) . handle , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> def OnExit ( self , widget , data = None ) : <EOL> self . exiting = True <EOL> gtk . main_quit ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> version = '<STR_LIT:.>' . join ( map ( str , list ( gtk . gtk_version ) ) ) <EOL> print ( '<STR_LIT>' % version ) <EOL> sys . excepthook = ExceptHook <EOL> settings = { <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : cefpython . LOGSEVERITY_INFO , <EOL> "<STR_LIT>" : GetApplicationPath ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : cefpython . GetModuleDirectory ( ) + "<STR_LIT>" , <EOL> "<STR_LIT>" : cefpython . GetModuleDirectory ( ) , <EOL> "<STR_LIT>" : "<STR_LIT>" % ( <EOL> cefpython . GetModuleDirectory ( ) , "<STR_LIT>" ) , <EOL> } <EOL> cefpython . Initialize ( settings ) <EOL> gobject . threads_init ( ) <EOL> PyGTKExample ( ) <EOL> gtk . main ( ) <EOL> cefpython . Shutdown ( ) </s>
