[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Word wrap in QLabel -  strange resizing
From:       Mads Ipsen <madsipsen () gmail ! com>
Date:       2011-08-22 9:04:54
Message-ID: 4E521BB6.3090503 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

If you set wordWrap to True for a QLabel in widget the layout, the 
resizing of the widget is kinda strange: The widget can be resized to 
nothing etc. I've attached a small example, displaying two widgets: One 
with and one without wordwrap. This must be a bug, right?

Best regards,

Mads

[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <font face="Bitstream Vera Sans Mono">Hi,<br>
      <br>
      If you set wordWrap </font>to True for a QLabel in widget the
    layout, the resizing of the widget is kinda strange: The widget can
    be resized to nothing etc. I've attached a small example, displaying
    two widgets: One with and one without wordwrap. This must be a bug,
    right?<br>
    <br>
    Best regards,<br>
    <br>
    Mads
  </body>
</html>

["word_wrap.py" (text/x-python)]

import sys
from PyQt4 import QtCore, QtGui

class Label(QtGui.QLabel):
    """
       Class for defining a word wrapped label.
    """
    def __init__(self, parent=None):
        """
           Constructor.
        """
        # Call base class constructor
        QtGui.QLabel.__init__(self, parent)

        # Add some text
        text = """Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do \
eiusmod tempor incididunt ut labore et dolore magna aliqua."""  self.setText(text)

class Widget(QtGui.QWidget):
    def __init__(self, word_wrap=False, parent=None):
        """
           Constructor.
        """
        # Call base class constructor
        QtGui.QWidget.__init__(self, parent)

        # Add some text
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)

        # Add some widgets
        label = Label()
        label.setWordWrap(word_wrap)
        layout.addWidget(label)

        push_button = QtGui.QPushButton('Press me')
        layout.addWidget(push_button)

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    widget1 = Widget(word_wrap=False)
    widget1.show()

    widget2 = Widget(word_wrap=True)
    widget2.show()

    sys.exit(app.exec_())



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic