简体   繁体   中英

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 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM