Did you think Chrome is the lightest web browser? Jua! With this tiny script, which uses the libwebkit-gtk library and weighs only 2 KBs, you will be able to browse the internet while consuming a minimum of memory and having a quite remarkable web experience, since the script uses the Webkit engine (in which Midori, Safari, Epiphany, etc. are also based), one of which got 100% Acid3 compatibility and has very good support for the new HTML5. |
Create a file with your favorite text editor. Paste the content below and save the file with the name "minibrowser.py".
#! / usr / bin / env python
importsys
import gtk
import webkit
DEFAULT_URL = 'http://www.google.com' # Change this as you Wish
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 (350, 20)
vbox = gtk.VBox (spacing = 5)
vbox.set_border_width (5)
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 ('% s'% url)
self._load (url)
def show (self):
self.window.show_all ()
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 ()
Then assign execute permissions
chmod + x minibrowser.py
To navigate, you just have to run it by typing ...:
python minibrowser.py http://usemoslinux.blogspot.com/
Via | Ubuntu Forums
Sure.
I don't know how to program in pyton but it seems that it uses the gtk library. Do I need to run it under gnome yes or yes? Can I run it under LXDE if I have gnome installed?
Thanks for the input!
Hello! Maybe this code was taken from here? The lines of code and their order are the same… 🙂
http://blog.marcelofernandez.info/2009/11/navegador-simple-con-pywebkitgtk/
regards
it works excellent I tried it on linux mint 9 64bits
Hello, Marcelo. Look, as the post clearly says (below, at the end) I got it from Ubuntu Forums. There they do not indicate any source so I assumed it was original. A hug! Paul.
Excellent this luxury! Greasy