[PyQt] sizing a QTextEdit...
Algis Kabaila
akabaila at pcug.org.au
Thu Sep 9 04:58:19 BST 2010
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
More information about the PyQt
mailing list