Advertisement
metalx1000

Python - Webkit - Zoom Text

Jun 13th, 2012
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import gtk, webkit
  4.  
  5. def go_but(widget):
  6.     add = addressbar.get_text()
  7.     if add.startswith("http://"):
  8.             web.open(add)
  9.     else:
  10.             add = "http://" + add
  11.             addressbar.set_text(add)
  12.             web.open(add)
  13.  
  14. def zoom_in(widget):
  15.      web.zoom_in()
  16.  
  17. def zoom_out(widget):
  18.      web.zoom_out()
  19.  
  20. win = gtk.Window()
  21. win.connect('destroy', lambda w: gtk.main_quit())
  22.  
  23. box1 = gtk.VBox()
  24. win.add(box1)
  25.  
  26. box2 = gtk.HBox()
  27. box1.pack_start(box2, False)
  28.  
  29.  
  30. addressbar = gtk.Entry()
  31. box2.pack_start(addressbar)
  32.  
  33. gobutton = gtk.Button("GO")
  34. box2.pack_start(gobutton)
  35. gobutton.connect('clicked', go_but)
  36.  
  37. zoom_in_button = gtk.Button("+")
  38. box2.pack_start(zoom_in_button)
  39. zoom_in_button.connect('clicked', zoom_in)
  40.  
  41. zoom_out_button = gtk.Button("-")
  42. box2.pack_start(zoom_out_button)
  43. zoom_out_button.connect('clicked', zoom_out)
  44.  
  45. scroller = gtk.ScrolledWindow()
  46. box1.pack_start(scroller)
  47.  
  48. web = webkit.WebView()
  49. scroller.add(web)
  50.  
  51. win.show_all()
  52.  
  53. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement