鱼C论坛

 找回密码
 立即注册
12
返回列表 发新帖
楼主: 清風

求助~~

[复制链接]
发表于 2024-2-17 11:43:29 | 显示全部楼层

要不自己写代码?现在 AI 的水平还无法解决一些高难度的问题。

点评

我很赞同!: 5.0
我很赞同!: 5
  发表于 2024-2-17 12:53
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2024-2-17 12:54:03 | 显示全部楼层
这个试试?

  1. from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QProgressBar, QLineEdit, QLabel, QMessageBox
  2. from PySide6.QtCore import QTimer, Qt
  3. import sys

  4. class WelcomeWindow(QMainWindow):
  5.     def __init__(self):
  6.         super().__init__()
  7.         self.setWindowTitle("欢迎")
  8.         self.setGeometry(100, 100, 280, 100)
  9.         self.progressBar = QProgressBar(self)
  10.         self.progressBar.setGeometry(50, 50, 200, 30)
  11.         self.initUI()

  12.     def initUI(self):
  13.         self.timer = QTimer(self)
  14.         self.timer.timeout.connect(self.handleProgress)
  15.         self.timer.start(100)
  16.         self.show()

  17.     def handleProgress(self):
  18.         currentValue = self.progressBar.value()
  19.         if currentValue < 100:
  20.             currentValue += 1
  21.             self.progressBar.setValue(currentValue)
  22.         else:
  23.             self.timer.stop()
  24.             self.openLoginWindow()

  25.     def openLoginWindow(self):
  26.         self.loginWindow = LoginWindow(self)
  27.         self.loginWindow.show()

  28. class LoginWindow(QMainWindow):
  29.     def __init__(self, parent=None):
  30.         super().__init__(parent)
  31.         self.attempts = 0
  32.         self.setWindowTitle("登录")
  33.         self.setGeometry(100, 100, 280, 100)
  34.         layout = QVBoxLayout()
  35.         self.label = QLabel("请输入密码:")
  36.         self.lineEdit = QLineEdit()
  37.         self.loginButton = QPushButton("登录")
  38.         self.loginButton.clicked.connect(self.checkPassword)
  39.         layout.addWidget(self.label)
  40.         layout.addWidget(self.lineEdit)
  41.         layout.addWidget(self.loginButton)
  42.         centralWidget = QWidget()
  43.         centralWidget.setLayout(layout)
  44.         self.setCentralWidget(centralWidget)

  45.     def checkPassword(self):
  46.         password = self.lineEdit.text()
  47.         if password == "correct":  # 假设"correct"是正确的密码
  48.             self.parent().close()  # 关闭欢迎窗体
  49.             self.close()  # 关闭登录窗体
  50.             self.mainWindow = MainWindow()  # 打开主窗体
  51.             self.mainWindow.show()
  52.         else:
  53.             self.attempts += 1
  54.             QMessageBox.warning(self, "错误", "密码错误!")
  55.             if self.attempts >= 3:
  56.                 QApplication.quit()

  57. class MainWindow(QMainWindow):
  58.     def __init__(self):
  59.         super().__init__()
  60.         self.setWindowTitle("主窗体")
  61.         self.setGeometry(100, 100, 400, 300)
  62.         layout = QVBoxLayout()
  63.         for i in range(12):
  64.             button = QPushButton(f"按钮 {i+1}")
  65.             layout.addWidget(button)
  66.         centralWidget = QWidget()
  67.         centralWidget.setLayout(layout)
  68.         self.setCentralWidget(centralWidget)

  69. if __name__ == "__main__":
  70.     app = QApplication(sys.argv)
  71.     welcomeWindow = WelcomeWindow()
  72.     sys.exit(app.exec_())
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2024-2-17 14:11:23 | 显示全部楼层

AI没懂的我意思    我也迷糊了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-23 13:49

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表