[PyKDE] PyKDE2 - First bug report

Jim Bublitz jbublitz at nwinternet.com
Sun Dec 2 19:21:33 GMT 2001


BUG: DCOPClient.tr ('foo') segfaults, DCOPClient.tr ('foo', 'bar')
doesn't exist.

tr() is used in translating program strings for
internationalization. tr() is inherited from QObject, and I expect
that no PyKDE2 descendant of QObject has a tr() that works (it
should be working in PyQt though). Don't expect tr() to work for
any PyKDE2 object that has this method (although if it does I'd like
to know).


WORKAROUND: Use i18n (const char *) or i18n (const char *, const
char *) - these globals are in the kdecore module, so use:

from kdecore import i18n, KMainWindow
from qt import QPopupMenu

class fooMain (KMainWindow):
    def __init__ (self, *args):
        text = i18n ('bar', 'foo')
        p    = QPopupMenu (self)
        id   = p.insertItem(i18n("&New"), self.fooNew)

You can also use QObject.tr() (it's a static method), and
'p.tr ("&New")' should also work in the example above. In either
case you lose the 'context' (name of the calling class), but KDE
doesn't preserve that anyway. kApp.translate should also work (kApp
is global). Overloading tr() might also work.


FIX: This doesn't appear to be a simple problem at the moment, and
it's even worse for KDE2.2.x. I have a temporary fix that still
needs to be tested thoroughly. Since there is a good workaround and
PyKDE2-3.0alpha3 with KDE2.2.x support is nearing completion, the
temporary fix will be applied to that release. There should be no
user-visible differences between the temporary fix and a permanent
fix when one becomes available.

Jim





More information about the PyQt mailing list