0
我剛開始學習PyQt,但我遇到了一些問題。這裏是我的代碼:PyQt4 Gui設計
class GUI(QtGui.QMainWindow):
'''
classdocs
'''
"""**********************************************************************"""
""" Constructor """
"""**********************************************************************"""
def __init__(self, parent = None):
self.app = QtGui.QApplication(sys.argv)
QtGui.QMainWindow.__init__(self)
"""******************************************************************"""
""" Settintg up the windows """
"""******************************************************************"""
self.resize(1024, 756)
self.setWindowTitle('Windscanner - Core Module')
self.setWindowIcon(QtGui.QIcon('icons/Windsock.png'))
""" Text Area """
self.messageField = QtGui.QTextEdit() # Alternative: QTextEdit
self.messageField.setReadOnly(True)
""" Input """
self.inputLine = QtGui.QLineEdit()
""" Send Button """
sendButton = QtGui.QPushButton('TCP: Send')
sendButton.setStatusTip('Send manually inserted message via TCP')
sendButton.setToolTip('Send manually inserted message via TCP')
self.connect(sendButton, QtCore.SIGNAL('clicked()'), self.f_sendbutton)
sendButton.setGeometry(300, 300, 250, 150);
""" Layout """
mainLayout = QtGui.QGridLayout()
mainLayout.addWidget(self.messageField)
mainLayout.addWidget(self.inputLine)
mainLayout.addWidget(sendButton)
""" Widget """
mainWidget = QtGui.QWidget()
mainWidget.setLayout(mainLayout)
self.setCentralWidget(mainWidget)
self.show()
sys.exit(self.app.exec_())
我的問題是如何定義文本區域和按鈕的大小和幾何? 我試過用
setGeometry()
但它並不真正的工作。