import sys from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLineEdit, QPushButton, QMessageBoxdef show_confirmation_dialog(text):msg = QMessageBox()msg.setWindowTitle("确认框")msg.setText(text)msg.exec_()def main():# 创建应用程序对象app = QApplication(sys.argv)# 创建主窗口mainWindow = QWidget()mainWindow.setWindowTitle("简单界面示例")# 创建文本输入框textInput = QLineEdit()textInput.setPlaceholderText("请输入文本")# 创建确认按钮confirmButton = QPushButton("确认")# 点击确认按钮时的动作def confirm_button_clicked():inputText = textInput.text()if inputText:show_confirmation_dialog("你输入的文本是:" + inputText)else:show_confirmation_dialog("请输入文本")confirmButton.clicked.connect(confirm_button_clicked)# 创建布局layout = QVBoxLayout()layout.addWidget(textInput)layout.addWidget(confirmButton)# 将布局设置为主窗口的布局mainWindow.setLayout(layout)# 显示主窗口mainWindow.show()# 运行应用程序sys.exit(app.exec_())if __name__ == "__main__":main()