[PyQt] sizing a QTextEdit...

Peter Milliken peter.milliken at gmail.com
Thu Sep 9 05:12:00 BST 2010


Sorry, that previous email should have explained that within the main QFrame
I am attempting to lay everything out using gridlayout.

On Thu, Sep 9, 2010 at 2:06 PM, Peter Milliken <peter.milliken at gmail.com>wrote:

> Probably not. The code snippet might be a bad example. I am attempting to
> create a QFrame in the MainWindow and populate it with a number of pairs of
> lQLabel/QLineEdit. One of the "pairs" needs to be a QLabel/QTextEdit and
> unfortunately as soon as I add that the grid seems to 'explode' - in the
> vertical direction.  I just want a QTextEdit sized about 3 or 4 times the
> height of a QLineEdit.
>
> Thanks for the suggestion
> Peter
>
>
> On Thu, Sep 9, 2010 at 1:58 PM, Algis Kabaila <akabaila at pcug.org.au>wrote:
>
>> On Thursday 09 September 2010 13:03:14 Peter Milliken wrote:
>> > I cannot work out how to (re)size a QTextEdit widget. I have tried
>> various
>> > methods, without success. I show one method in the following code
>> snippet,
>> > I would appreciate it if somebody could point out my error :-)
>> >
>> > Thanks
>> > Peter
>> >
>> > from PyQt4.QtCore import *
>> > from PyQt4.QtGui import *
>> > import PyQt4.Qt as Qt
>> > import sys
>> >
>> > class Test(QMainWindow):
>> >   def __init__ (self, parent = None):
>> >     super(Test, self).__init__(parent)
>> >     self.frame = QFrame()
>> >     self.setCentralWidget(self.frame)
>> >     grid = QGridLayout()
>> >     grid.addWidget(QLabel("Desc:"), 0, 0)
>> >     self.description = QTextEdit()
>> >     currentSize = self.description.size()
>> >     print currentSize
>> >     currentSize.scale(50,25, Qt.IgnoreAspectRatio)
>> >     self.description.resize(currentSize)
>> >     grid.addWidget(self.description, 0, 1)
>> >     self.frame.setLayout(grid)
>> >
>> > if __name__ == '__main__':
>> >
>> >   app = QApplication(sys.argv)
>> >
>> >   Gui = Test()
>> >   Gui.show()
>> >   app.exec_()
>>
>> Would the following satisfy your immediate needs?
>>
>> from PyQt4.QtGui import *
>> import PyQt4.Qt as Qt
>> import sys
>>
>> class Test(QMainWindow):
>>  def __init__ (self, parent = None):
>>    super(Test, self).__init__(parent)
>>     self.resize(600, 300) # Added statement
>>     self.frame = QFrame()
>>    self.setCentralWidget(self.frame)
>>    grid = QGridLayout()
>>    grid.addWidget(QLabel("Desc:"), 0, 0)
>>    self.description = QTextEdit()
>>    currentSize = self.description.size()
>> #    print currentSize
>> #    currentSize.scale(50,25, Qt.IgnoreAspectRatio)
>>    self.description.resize(currentSize)
>>    grid.addWidget(self.description, 0, 1)
>>    self.frame.setLayout(grid)
>> if __name__ == '__main__':
>>  app = QApplication(sys.argv)
>>  Gui = Test()
>>  Gui.show()
>>  app.exec_()
>>
>> --
>> OldAl
>> akabaila at pcug.org.au
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100909/705fe621/attachment.html>


More information about the PyQt mailing list