代码
'''禁止窗体显示最大化按钮及调整窗体大小
'''
from PyQt5 import QtCore, QtWidgetsclass Ui_MainWindow ( object ) : def setupUi ( self, MainWindow) : MainWindow. setObjectName( "MainWindow" ) MainWindow. resize( 500 , 300 ) self. centralwidget = QtWidgets. QWidget( MainWindow) self. centralwidget. setObjectName( "centralwidget" ) MainWindow. setCentralWidget( self. centralwidget) MainWindow. setFixedSize( MainWindow. width( ) , MainWindow. height( ) ) ; self. retranslateUi( MainWindow) QtCore. QMetaObject. connectSlotsByName( MainWindow) def retranslateUi ( self, MainWindow) : _translate = QtCore. QCoreApplication. translateMainWindow. setWindowTitle( _translate( "MainWindow" , "禁止窗体显示最大化按钮及调整窗体大小" ) )
if __name__ == '__main__' : import sysapp = QtWidgets. QApplication( sys. argv) MainWindow = QtWidgets. QMainWindow( ) ui = Ui_MainWindow( ) ui. setupUi( MainWindow) MainWindow. show( ) sys. exit( app. exec_( ) )
效果