Changes

Line 7: Line 7:  
[[PyGTK/Smooth_Animation_with_PyGTK]]
 
[[PyGTK/Smooth_Animation_with_PyGTK]]
   −
== WebView ==
+
== WebKit WebView ==
Use the WebView in a widget.
+
 
import os
+
  from gi.repository import WebKit
  import hulahop
+
  from gi.repository import Gtk
  from sugar import env
  −
hulahop.startup(os.path.join(env.get_profile_path(), 'gecko'))
   
   
 
   
  from hulahop.webview import WebView
+
  WINDOW_WIDTH, WINDOW_HEIGHT = 700, 500
 
   
 
   
  import gtk
+
  # create window:
 
   
 
   
  win = gtk.Window(gtk.WINDOW_TOPLEVEL)
+
  def _destroy_cb(widget, data=None):
win.set_size_request(800,600)
+
    Gtk.main_quit()
win.connect('destroy', gtk.main_quit)
  −
wv = WebView()
  −
wv.load_uri('http://wiki.laptop.org/go/Guido_van_Robot')
  −
wv.show()
   
   
 
   
  win.add(wv)
+
  window = Gtk.Window()
 +
window.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
 +
window.connect("destroy", _destroy_cb)
 +
window.show()
 
   
 
   
  win.show()
+
  # create and add scrolled window:
  gtk.main()
+
s = Gtk.ScrolledWindow()
 +
window.add(s)
 +
  s.show()
 
   
 
   
=== Notes ===
+
# create and add webview:
* I'm not sure what the purpose is of the call to hulahop.startup as the documentation is rather sparse. I only knows it's needed to get it to work [[User:Stas_z|Stas Zytkiewicz]] 2 Dec 2007
+
v = WebKit.WebView()
 +
s.add(v)
 +
v.show()
 +
 +
# load google page:
 +
v.load_uri('http://wiki.laptop.org')
 +
 +
Gtk.main()
    
== Toolbar ==
 
== Toolbar ==
296

edits