Monthly Archives: July 2008

Rng 1.0 in unstable

I’ve finished the porting of rng from qt3 to qt4 and uploaded it to unstable. It has some minor regressions compared to the qt3 version, like the localization of the qt4 widgets which isn’t working yet and that the column which sorts the table isn’t saved and restored properly on startup, but it closes many other bugs and it doesn’t crash anymore.

The new version doesn’t bring so much new features so far, but since it’s using much of the stuff which came with QT4, like the QTableModel and the QWebView, it runs much faster in many cases, e.g. when sorting or filtering the table.

Ah, and last but but not least: thanks to WebKit rng even passes acid1 and acid2. Doesn’t yet pass acid3 but I guess someone is already working on it :)

rng passing acid2

Porting rng to QT4

Today I was busy porting reportbug-ng to QT4. One really cool thing I noticed is the new QWebView widget, which is the main widget of the QWebKit module. It works surprisingly easy compared to the good old QTextBrowser of QT3 — now you can just throw an URL at it and it will render the page nicely complete with CSS, images, etc.

Here’s the obligatory screenshot:

reportbug-ng qt4

as you can see, the bugreport looks much better than in the old version of rng. WebKit does a really good job rendering the HTML, I think the fonts look even smoother than under firefox.

To ease the transition to from QT3 to QT4 I’ve extracted all the Debian BTS specific stuff to python-debianbts and uploaded it to unstable. Rng uses it to query our Bug Tracking System via it’s SOAP interface and get the data in Python’s native data types.

There is still the problem with rng (QT3) crashing when showing bugreports. I’ve investigated the problem a bit and found out that it is not rng’s fault but probably a problem with python-qt3 or one of it’s underlying libs. QTextBrowser causes segfaults in nearly 50% of the cases where you try to render html from a different thread: here’s an easy way to reproduce:

# crash.py
# Usage: python crash.py "some text"
#        python crash.py "some evil html"

from qt import *
import sys
import threading

class Form(QMainWindow):
    def __init__(self,parent = None,name = None,fl = 0):
        QMainWindow.__init__(self,parent,name,fl)
        self.browser = QTextBrowser(self, "browser")
        self.setCentralWidget(self.browser)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print 'Usage: %s "some text"' % sys.argv[0]
        sys.exit()
    s = str(sys.argv[1])

    # setup qt stuff with a browser
    app = QApplication(sys.argv)
    app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
    form = Form()
    app.setMainWidget(form)
    form.show()

    # start a different thread and try to set the text in the browser
    # we wait 1.0 second -- just to make sure the change happens after the
    # start of app.exec_loop() below
    t = threading.Timer(1.0, form.browser.setText, (s, ))
    t.start()

    app.exec_loop()

QWebView doesn't seem to have this problem, the QT4 version of rng didn't crash a single time.

I'm not quite ready with the porting to QT4, and since I'll be quite busy during the next weeks I suppose it will take a few weeks until the new version will be updated to unstable.

Maximize vs Maximize to Preferred Size

In times where screen resolutions of 1600x… and above are becoming more and more common, I wonder if the maximize window button which enlarges a window to take all the available space on the desktop is still as useful as it used to be.

I noticed that some (if not all, I’m not a Mac user) applications on Mac only maximize their windows depending on the content of the window. For example if you maximize the window of your word processor, the window becomes only as wide as necessary to make the whole page visible. This doesn’t just look better on very large monitors, it is also more usable than a simple maximize since it doesn’t unnecessarily hide other windows.

Is there a window manager for Linux which does something similar, or better: is something like this possible with KDE? I know that QT widgets have a “preferred size” — shouldn’t it be possible to have a maximize to preferred size button? It’s surely not useful for every application, but may applications only need a quite small main window and look very ugly when maximized.

Segfaults Everywhere

Dear Lazyweb,

A few weeks ago rng started to show some segfaulty behavior. I’ve absolutely no idea what’s going on, since Python code usually doesn’t segfault. I guess the problem lies in the qt3-bindings rng uses — does someone know how to verify this?

There is a backtrace which seems to show that the problem lies somewhere in /usr/lib/python2.5/site-packages/qt.so but I’m not entirely sure how to interpret that.

Tab Completion in Python’s Interactive Mode

While browsing the python docs, I accidentally stumbled upon this today. It describes how to get Tab completion in Python’s interactive shell:

  1. Create a ~/.pythonrc file with the following content:
    try:
        import readline
    except ImportError:
        print "Module readline not available."
    else:
        import rlcompleter
        readline.parse_and_bind("tab: complete")
    
  2. Put this somewhere in your ~/.bashrc
    export PYTHONSTARTUP=~/.pythonrc

The .pythonrc will be executed every time the Python interpreter is started but not when it executes a script.

How does it look like?

$ python
Python 2.5.2 (r252:60911, Jun 25 2008, 17:58:32)
[GCC 4.3.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> l = []
>>> l.
l.__add__           l.__getslice__      l.__ne__            l.append
l.__class__         l.__gt__            l.__new__           l.count
l.__contains__      l.__hash__          l.__reduce__        l.extend
l.__delattr__       l.__iadd__          l.__reduce_ex__     l.index
l.__delitem__       l.__imul__          l.__repr__          l.insert
l.__delslice__      l.__init__          l.__reversed__      l.pop
l.__doc__           l.__iter__          l.__rmul__          l.remove
l.__eq__            l.__le__            l.__setattr__       l.reverse
l.__ge__            l.__len__           l.__setitem__       l.sort
l.__getattribute__  l.__lt__            l.__setslice__
l.__getitem__       l.__mul__           l.__str__
>>> l.

Very cool! Why is this hidden so deep in the docs and not enabled by default?