touchscreen scrolling into python web browser

426 Views Asked by At

I'm making a python web browser. I would like to use the feature of my touchscreen to scroll the page down. (like most apps or navigation on phone, drag with the finger.)

My browser now :

#!/usr/bin/env python
import sys
import gtk
import webkit
DEFAULT_URL = 'http://localhost/'
class SimpleBrowser: # needs GTK, Python, Webkit-GTK
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.window.connect('delete_event', self.close_application)
        self.window.set_default_size(1366, 743)
        self.window.set_position(0)
        vbox = gtk.VBox(spacing=0)
        vbox.set_border_width(0)
        self.txt_url = gtk.Entry()
        self.txt_url.connect('activate', self._txt_url_activate)
        self.scrolled_window = gtk.ScrolledWindow()
        self.webview = webkit.WebView()
        self.scrolled_window.add(self.webview)
        vbox.pack_start(self.scrolled_window, fill=True, expand=True)
        self.window.add(vbox)
    def _txt_url_activate(self, entry):
        self._load(entry.get_text())
    def _load(self, url):
        self.webview.open(url)
    def open(self, url):
        self.txt_url.set_text(url)
        self.window.set_title('Mainpage')
        self._load(url)
    def show(self):
        self.window.show_all()
        #self.window.fullscreen()
    def close_application(self, widget, event, data=None):
        gtk.main_quit()
if __name__ == '__main__':
    if len(sys.argv) > 1:
        url = sys.argv[1]
    else:
        url = DEFAULT_URL
    gtk.gdk.threads_init()
    browser = SimpleBrowser()
    browser.open(url)
    browser.show()
    gtk.main()
0

There are 0 best solutions below