Example #1
0
#!/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()
Example #2
0
#!/usr/bin/env python
import os.path
import sys
sys.path = [ os.path.abspath( os.path.join( os.path.dirname(__file__),"..", ".."))] + \
           sys.path

from pyggi.gtk3 import GtkWindow, GtkScrolledWindow
from pyggi import gtk3
from pyggi.webkit3 import WebKitWebView

#Create the GUI component stack
window = GtkWindow(gtk3.GTK_WINDOW_TOPLEVEL)
window.set_default_size(1200, 800)
window.set_title("Example2: Use Python to Manipulate a Javascript Element")
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()