[SOLVED] PySide : Failing to create specialized label



  • Hello there.

    In my user interface i'll be having quite a number of labels and i simply don't like the default font size, so i thought about creating a specialized label.

    Here's the code:

    @
    from PySide import QtGui
    class MyLabel(QtGui.QLabel):
    def init(self, labeltext):
    super(MyLabel, self).init(labeltext)
    font = QtGui.QFont()
    font.setPointSize(12)
    self.setFont(font)
    @

    and that's it.When I try to create an instance from this label, the interpreter just restarts (or in case of the Python commandline, the window closes).

    Am I doing something wrong?

    Thanks



  • Ok.I just didn't create a main application before creating a label instance:

    @
    import sys
    app = QtGui.QApplication(sys.argv)

    label = MyLabel('Hello Label!')

    label.show()
    @

    works nicely!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.