#!/usr/bin/env python from pyggi.gtk3 import GtkWindow, GtkScrolledWindow from pyggi import gtk3 from pyggi.webkit3 import WebKitWebView window = GtkWindow( gtk3.GTK_WINDOW_TOPLEVEL ) window.set_default_size( 1200, 800 ) window.set_title("Example1: Load a Web Page") scrolled = GtkScrolledWindow( None, None ) window.add( scrolled ) webview = WebKitWebView() scrolled.add( webview ) webview.open( "http://www.python.org" ) window.show_all() window.connect( "delete-event", gtk3.main_quit ) def main(): gtk3.main() if __name__ == "__main__": main()
from pyggi.webkit3 import WebKitWebView, WebKitWebSettings window = GtkWindow(gtk3.GTK_WINDOW_TOPLEVEL) window.set_default_size(1200, 800) window.set_title("Example1: Load a Web Page") scrolled = GtkScrolledWindow(None, None) window.add(scrolled) webview = WebKitWebView() settings = webview.get_settings() statc = settings.set("enable-webgl", True, None) webview.set_settings(settings) aquarium.initialize_aquarium(webview.get_main_frame().get_global_context(), webview.on_view_ready) import logging logging.error("ENABLE: ") scrolled.add(webview) #webview.open( "http://learningwebgl.com/lessons/lesson04/index.html" ) webview.open("file:///%s/aquarium.html" % os.path.dirname(__file__)) window.show_all() window.connect("delete-event", gtk3.main_quit) def main(): gtk3.main() if __name__ == "__main__": main()
#sleep here. Doing this in the gtk main thread will hamper #the display of the GUI, locking any display updates out #during the sleep call import time time.sleep(0.2) thread = Thread() thread._active = True from pyggi import gobject #start the color update thread ONLY when view is ready: webview.on_view_ready(thread.start) def do_quit(): thread._active = False gtk3.main_quit() #on delete of window, exit: window.connect("delete-event", do_quit) def main(): gtk3.main() if __name__ == "__main__": main()
def run(self): while self._active: #Must run actual javascript manipulation in gtk main thread: gobject.idle_add( update_color, 20 ) #we put this code in a real Python thread, to be able to #sleep here. Doing this in the gtk main thread will hamper #the display of the GUI, locking any display updates out #during the sleep call import time time.sleep(0.2) thread = Thread() thread._active = True from pyggi import gobject #start the color update thread ONLY when view is ready: webview.on_view_ready(thread.start) def do_quit(): thread._active = False gtk3.main_quit() #on delete of window, exit: window.connect( "delete-event", do_quit ) def main(): gtk3.main() if __name__ == "__main__": main()