[PyQt] Number of characters in QLabel - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [PyQt] Number of characters in QLabel (/thread-5477.html) |
Number of characters in QLabel - hzcodec - Oct-06-2017 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. RE: Number of characters in QLabel - Alfalfa - Oct-10-2017 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. RE: Number of characters in QLabel - hzcodec - Oct-13-2017 OK, that simple . Thank You for your tip. |