Changes

Line 1: Line 1: −
{{OLPC}}
   
{{Translations}}
 
{{Translations}}
   −
The [[Sugar-api-doc|Sugar Almanac]] also has lots of code snippets.
+
The [[Development_Team/Almanac|Sugar Almanac]] also has lots of code snippets.
    
== Smooth animation ==
 
== Smooth animation ==
Line 8: 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'))
+
  WINDOW_WIDTH, WINDOW_HEIGHT = 700, 500
 +
 +
# create window:
 
   
 
   
  from hulahop.webview import WebView
+
  def _destroy_cb(widget, data=None):
 +
    Gtk.main_quit()
 
   
 
   
  import gtk
+
  window = Gtk.Window()
 +
window.resize(WINDOW_WIDTH, WINDOW_HEIGHT)
 +
window.connect("destroy", _destroy_cb)
 +
window.show()
 
   
 
   
  win = gtk.Window(gtk.WINDOW_TOPLEVEL)
+
  # create and add scrolled window:
  win.set_size_request(800,600)
+
  s = Gtk.ScrolledWindow()
  win.connect('destroy', gtk.main_quit)
+
  window.add(s)
wv = WebView()
+
  s.show()
wv.load_uri('http://wiki.laptop.org/go/Guido_van_Robot')
  −
  wv.show()
   
   
 
   
  win.add(wv)
+
  # create and add webview:
 +
v = WebKit.WebView()
 +
s.add(v)
 +
v.show()
 
   
 
   
  win.show()
+
  # load google page:
  gtk.main()
+
  v.load_uri('http://wiki.laptop.org')
 
   
 
   
=== Notes ===
+
Gtk.main()
* 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
      
== Toolbar ==
 
== Toolbar ==
Line 224: Line 229:  
[[Category:HowTo]]
 
[[Category:HowTo]]
 
[[Category:Sugar]]
 
[[Category:Sugar]]
[[Category:Developers]]
+
[[Category:Developer]]
296

edits