<s> import ctypes , os , sys <EOL> libcef_so = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , '<STR_LIT>' ) <EOL> if os . path . exists ( libcef_so ) : <EOL> ctypes . CDLL ( libcef_so , ctypes . RTLD_GLOBAL ) <EOL> if <NUM_LIT> <= sys . hexversion < <NUM_LIT> : <EOL> import cefpython_py27 as cefpython <EOL> else : <EOL> raise Exception ( "<STR_LIT>" % sys . version ) <EOL> else : <EOL> from cefpython3 import cefpython <EOL> from PyQt4 import QtGui <EOL> from PyQt4 import QtCore <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 MainWindow ( QtGui . QMainWindow ) : <EOL> mainFrame = None <EOL> def __init__ ( self ) : <EOL> super ( MainWindow , self ) . __init__ ( None ) <EOL> self . createMenu ( ) <EOL> self . mainFrame = MainFrame ( self ) <EOL> self . setCentralWidget ( self . mainFrame ) <EOL> self . resize ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . setWindowTitle ( '<STR_LIT>' ) <EOL> self . setFocusPolicy ( QtCore . Qt . StrongFocus ) <EOL> def createMenu ( self ) : <EOL> menubar = self . menuBar ( ) <EOL> filemenu = menubar . addMenu ( "<STR_LIT>" ) <EOL> filemenu . addAction ( QtGui . QAction ( "<STR_LIT>" , self ) ) <EOL> filemenu . addAction ( QtGui . QAction ( "<STR_LIT>" , self ) ) <EOL> aboutmenu = menubar . addMenu ( "<STR_LIT>" ) <EOL> def focusInEvent ( self , event ) : <EOL> pass <EOL> def closeEvent ( self , event ) : <EOL> self . mainFrame . browser . CloseBrowser ( ) <EOL> class MainFrame ( QtGui . QX11EmbedContainer ) : <EOL> browser = None <EOL> plug = None <EOL> def __init__ ( self , parent = None ) : <EOL> super ( MainFrame , self ) . __init__ ( parent ) <EOL> gtkPlugPtr = cefpython . WindowUtils . gtk_plug_new ( int ( self . winId ( ) ) ) <EOL> print ( "<STR_LIT>" + str ( self . winId ( ) ) ) <EOL> print ( "<STR_LIT>" + str ( gtkPlugPtr ) ) <EOL> """<STR_LIT>""" <EOL> windowInfo = cefpython . WindowInfo ( ) <EOL> windowInfo . SetAsChild ( gtkPlugPtr ) <EOL> self . browser = cefpython . CreateBrowserSync ( windowInfo , <EOL> browserSettings = { } , <EOL> navigateUrl = "<STR_LIT>" + GetApplicationPath ( "<STR_LIT>" ) ) <EOL> cefpython . WindowUtils . gtk_widget_show ( gtkPlugPtr ) <EOL> self . show ( ) <EOL> def moveEvent ( self , event ) : <EOL> pass <EOL> def resizeEvent ( self , event ) : <EOL> pass <EOL> class CefApplication ( QtGui . QApplication ) : <EOL> timer = None <EOL> def __init__ ( self , args ) : <EOL> super ( CefApplication , self ) . __init__ ( args ) <EOL> self . createTimer ( ) <EOL> def createTimer ( self ) : <EOL> self . timer = QtCore . QTimer ( ) <EOL> self . timer . timeout . connect ( self . onTimer ) <EOL> self . timer . start ( <NUM_LIT:10> ) <EOL> def onTimer ( self ) : <EOL> cefpython . MessageLoopWork ( ) <EOL> def stopTimer ( self ) : <EOL> self . timer . stop ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print ( "<STR_LIT>" % QtCore . PYQT_VERSION_STR ) <EOL> print ( "<STR_LIT>" % QtCore . qVersion ( ) ) <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> switches = { <EOL> } <EOL> cefpython . Initialize ( settings , switches ) <EOL> app = CefApplication ( sys . argv ) <EOL> mainWindow = MainWindow ( ) <EOL> mainWindow . show ( ) <EOL> app . exec_ ( ) <EOL> app . stopTimer ( ) <EOL> del mainWindow <EOL> del app <EOL> cefpython . Shutdown ( ) </s>
