Python Forum

Full Version: Number of characters in QLabel
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying out Qt4 and just want to print out a string in a window. Now, the string is clipped. All characters are not printed. So what am I missing?
FYI, I'm using python 2.7 on Ubuntu dist.

import sys
from PyQt4 import QtGui
from PyQt4 import QtCore

class ProdTestMonitor(QtGui.QMainWindow):

    def __init__(self):
        super(ProdTestMonitor, self).__init__()
        self.setGeometry(100, 30, 500, 300)
        self.initUI()

    def initUI(self):

        comPortLbl = QtGui.QLabel(self)
        comPortLbl.move(20, 100)
        comPortLbl.setText('This line is just to long:')

def main():
    app = QtGui.QApplication(sys.argv)
    frame = ProdTestMonitor()
    frame.show()
    sys.exit(app.exec_())

if __name__ == "__main__":
    main()
Thanks in advance.
You are using the default size of the label, which is too short for your string. Just add something like:

        comPortLbl.resize(400, 20)

Also, since you are beginning you should work with Qt5 instead of Qt4. It will help maintaining your applications in the future.
OK, that simple Blush.

Thank You for your tip.