Skip to content

Instantly share code, notes, and snippets.

@banthar
Last active December 31, 2015 18:59
Show Gist options
  • Save banthar/8030357 to your computer and use it in GitHub Desktop.
Save banthar/8030357 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import gtk, webkit, sys, time, gobject
class Browser:
def __init__(self, window, url):
self.window = window
self.view = (webkit.WebView(), webkit.WebView())
self.url = url
self.open()
window.add(self.view[0])
window.add(self.view[1])
def open(self):
self.handler = self.view[0].connect("notify::load-status", lambda a,b: self.swap())
self.view[0].open(self.url)
def swap(self):
status = self.view[0].get_property('load-status')
LOAD_FINISHED = 2
LOAD_FAILED = 4
if status == LOAD_FINISHED or status == LOAD_FAILED:
self.view[0].disconnect(self.handler)
self.view[0].show()
self.view = (self.view[1], self.view[0])
self.view[0].hide()
def load():
self.open()
return False
gobject.timeout_add(1000, load)
def main():
if len(sys.argv)!=2:
print "usage: "+sys.argv[0]+" url"
return 1
w = gtk.Window()
w.set_title(sys.argv[0])
w.connect("destroy", gtk.main_quit)
screen = w.get_screen()
w.resize(screen.get_width(), screen.get_height())
w.set_sensitive(False)
panel = gtk.VBox()
w.add(panel)
browser = Browser(panel, sys.argv[1])
w.show_all()
w.fullscreen()
gtk.main()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment