[PyKDE] pyuic doesn't mind naming stuff "name"

Jonathan Gardner jgardn at alumni.washington.edu
Mon Feb 4 12:26:03 GMT 2002


I discovered a bug in pyuic. If you build a widget with a custom widget of 
class "name" inside, it will generate code that looks like this:

from name import name

class test(QWidget):
    def __init__(self,parent = None,name = None,fl = 0):
        QWidget.__init__(self,parent,name,fl)

        if name == None:
            self.setName('test_AUTO')

        self.resize(592,480)
        self.setCaption(self.tr("test"))

        self.Name = name(self,'Name')
        self.Name.setGeometry(QRect(290,110,60,20))

This was unexpected behavior. At least pyuic should have said you can't have 
widgets called "name", "self", "parent" or "fl". At best, it should have 
produced code that looks like this or something:

from name import name

class test(QWidget):
    def __init__(self,parent = None,name = None,fl = 0):
        QWidget.__init__(self,parent,name,fl)

        if name == None:
            self.setName('test_AUTO')

        self.resize(592,480)
        self.setCaption(self.tr("test"))

        name = globals()['name']
        self.Name = name(self,'Name')
        self.Name.setGeometry(QRect(290,110,60,20))

Jonathan




More information about the PyQt mailing list