コード例 #1
0
ファイル: example2.py プロジェクト: nak/pywebkit3
scrolled = GtkScrolledWindow(None, None)
window.add(scrolled)
webview = WebKitWebView()
scrolled.add(webview)

#open the example html in the view and show all components
import os.path
webview.open(
    os.path.join(os.path.dirname(os.path.abspath(__file__)), "example2.html"))
window.show_all()

#setup the environment and get the javascript object
color_block = None
#must get the object only when javascript has been processed,
#so setup callback
context = webview.get_main_frame().get_global_context()


def tryit(*args):
    window = context.get_jsobject("window")
    window.alert("Test of setTimeout callback into Python")


def import_element():
    window = context.get_jsobject("window")
    window.setTimeout(tryit, 100)
    global color_block
    color_block = context.get_jsobject("color_block", can_call=False)
    assert (color_block)

コード例 #2
0
ファイル: example2.py プロジェクト: nak/pywebkit3
scrolled = GtkScrolledWindow( None, None )
window.add( scrolled )
webview = WebKitWebView()
scrolled.add( webview )

#open the example html in the view and show all components
import os.path
webview.open( os.path.join( os.path.dirname(os.path.abspath(__file__)),"example2.html" ))
window.show_all()


#setup the environment and get the javascript object
color_block = None
#must get the object only when javascript has been processed,
#so setup callback 
context = webview.get_main_frame().get_global_context()

def tryit(*args):
    window = context.get_jsobject("window")
    window.alert("Test of setTimeout callback into Python")

def import_element():
    window = context.get_jsobject("window")
    window.setTimeout( tryit ,100)
    global color_block
    color_block = context.get_jsobject("color_block", can_call=False)
    assert(color_block)

webview.on_view_ready( import_element )

#set up a loop to continually increment the color
コード例 #3
0
import aquarium
from pyggi.gtk3 import GtkWindow, GtkScrolledWindow
from pyggi import gtk3
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()
コード例 #4
0
ファイル: example4.py プロジェクト: nak/pywebkit3
import aquarium
from pyggi.gtk3 import GtkWindow, GtkScrolledWindow
from pyggi import gtk3
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__":