PyQt4 Gui designing
I just started to lear the PyQt, but I got some problem. Here is my code:
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_() )
My 开发者_Python百科question is how can I define the size and geometry of the textarea and the button? I tryed to use the
setGeometry()
but it not really working.
You can use:
sendButton.setMinimumSize()
and
mainLayout.setRowMinimumHeight()
精彩评论