非常抱歉,下面是修正后的代码,保持了正确的Python格式:import sys
from PySide6.QtCore import Qt, QThread, Signal
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QLineEdit, QPushButton, QProgressBar, QMessageBox
class BassWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("BassWindow")
self.setGeometry(0, 0, 1440, 900)
self.setStyleSheet("background-color: blue;")
self.options_btn = QPushButton("选项调整", self)
self.options_btn.move(self.width() - 150, self.height() - 80)
self.options_btn.clicked.connect(self.open_options)
self.exit_btn = QPushButton("退出", self)
self.exit_btn.move(self.width() - 80, self.height() - 80)
self.exit_btn.clicked.connect(self.close)
self.welcome_label = QLabel(self)
self.welcome_label.setAlignment(Qt.AlignCenter)
self.welcome_label.setText("欢迎")
self.welcome_label.setGeometry(0, 0, self.width(), self.height())
self.welcome_label.setStyleSheet("font-size: 48px;")
self.username_label = QLabel("用户名:", self)
self.username_label.move(self.width() / 2 - 100, self.height() / 2)
self.username_input = QLineEdit(self)
self.username_input.move(self.width() / 2, self.height() / 2)
self.password_label = QLabel("密码:", self)
self.password_label.move(self.width() / 2 - 100, self.height() / 2 + 50)
self.password_input = QLineEdit(self)
self.password_input.move(self.width() / 2, self.height() / 2 + 50)
self.password_input.setEchoMode(QLineEdit.Password)
self.progress_thread = ProgressThread()
self.progress_thread.finished.connect(self.check_credentials)
self.buttons_layout = QVBoxLayout()
self.buttons_layout.addWidget(QPushButton("按钮1", self))
self.buttons_layout.addWidget(QPushButton("按钮2", self))
self.buttons_layout.addWidget(QPushButton("按钮3", self))
self.target_window = QWidget(self)
self.target_window.setGeometry(self.width() / 2 - 150, self.height() / 2 - 100, 300, 200)
self.target_window.setLayout(self.buttons_layout)
self.target_window.hide()
def show_welcome_animation(self):
# 在这里实现欢迎界面的动画效果
pass
def open_options(self):
print("打开选项调整界面")
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
self.close()
def open_target_window(self):
self.target_window.show()
def check_credentials(self):
username = self.username_input.text()
password = self.password_input.text()
# 模拟验证用户名和密码是否正确
if username == "admin" and password == "123456":
self.open_target_window()
else:
QMessageBox.warning(self, "提示", "用户名或密码错误!")
class WindowA(BassWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("WindowA")
class WindowB(BassWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("WindowB")
class WindowC(BassWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("WindowC")
class ProgressThread(QThread):
finished = Signal()
def run(self):
for i in range(101):
self.progress = i
self.msleep(100) # 模拟耗时操作
self.finished.emit()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = BassWindow()
window.show()
sys.exit(app.exec())
以上代码已经修正了Python格式,希望能够满足您的需求!
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。 |