cookbook

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

cookbook

Unread post by machinebacon » Thu May 23, 2013 10:47 am

This is basically a mini-webbrowser that can display HTML pages on a webkit canvas. Best to use for single websites. Depends on python-webkit.

Code: Select all

#!/usr/bin/env python

import gtk, webkit

def go_but(widget):
    add = addressbar.get_text()
    if add.startswith("http://"):
       web.open(add)
    else:
       add = "http://" + add
       addressbar.set_text(add)
       web.open(add)

def	new_title(view, frame, title):
	win.set_title(title)

def	on_click_link(view, frame):
	uri=frame.get_uri()
	#addressbar.set_text(uri)

win = gtk.Window()
win.set_default_size(890,700)
win.connect('destroy', lambda w: gtk.main_quit())

box1 = gtk.VBox()
win.add(box1)

box2 = gtk.HBox()
box1.pack_start(box2, False)


#addressbar = gtk.Entry()
#addressbar.connect("activate", go_but)
#box2.pack_start(addressbar)

#gobutton = gtk.Button("GO")
#box2.pack_start(gobutton, False)
#gobutton.connect('clicked', go_but)

scroller = gtk.ScrolledWindow()
box1.pack_start(scroller)

web = webkit.WebView()
web.open("http://www.ixquick.com")
#web.open("file:///path/to/index.html")
web.connect("title-changed", new_title)
web.connect("load-committed", on_click_link)

scroller.add(web)

win.show_all()

gtk.main()
..gnutella..

Post Reply