World’s smallest IPv6 compatible web browser program

For a long time now I’ve become a fan of the python+Qt combination. It is great to have an easy to learn, easy to use language with great portability and minimalistic syntax.

The following program has become my favorite showcase for python. To my knowledge, it is the smallest, easier to understand, portable, IPv6 compatible web browser in the world.

If you have IPv6 connectivity just lunch python and copy-paste it save it to a file and run it (it may crash python otherwise):

[python]
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app=QApplication([])
win=QMainWindow()
w=QWebView(win)
win.setCentralWidget(w)
w.setUrl(QUrl("http://ipv6.google.com/"))
win.show()
app.exec_()
[/python]

If you don’t then you can try the IPv4 version:

[python]
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app=QApplication([])
win=QMainWindow()
w=QWebView(win)
win.setCentralWidget(w)
w.setUrl(QUrl("http://www.google.com/"))
win.show()
app.exec_()
[/python]

In order to be able to run it you’ll need the Qt4 library and the python Qt bindings. If you’re under debian just run:

[bash light=”true”]
# apt-get install python-qt4
[/bash]

This should work at least under Linux, Windows, Maemo and perhaps Symbian.

3 comments

  1. Στέφανε ευχαριστώ για το παράδειγμα, είναι πραγματικά πολύ ενδιαφέρον. Γνωρίζεις εαν υπάρχει κάποιο application για να κάνεις develop το gui, κάτι σαν το glade, για qt?

    Ψάχνω για κάτι απλά για να σχεδιάζω και όχι ένα ολοκληρο qt development ide

    Like

    1. Qt-Designer is what you’re looking for.

      Under debian you can get it with:

      [bash light=”true”]
      # apt-get install qt4-designer
      [/bash]

      and run it with:

      [bash light=”true”]
      $ designer-qt4
      [/bash]

      Like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.