【发布时间】:2020-07-31 16:00:22
【问题描述】:
我正在构建一个小型扫雷克隆,我在这里有一个功能,用于用户单击炸弹按钮显示“boom”的事件,但我还想添加一个功能,其中弹出菜单之类的提示提示用户,并为他们提供两个按钮,一个继续,另一个要求开始新游戏。
def buttonClickedkill(self):
# sender() tells us who caused the action to take place
clicked = self.sender()
#letter=clicked.text() # the buttons have the letters on them
#print(f"Button -{letter}- was clicked!")
# 1) Disable the button
clicked.setEnabled(False)
clicked.setText("boom")
QMainWindow.__init__(self)
所以我想添加另一个功能,其中弹出的东西会说:
对不起,你击中炸弹死了!
继续?新游戏!
“继续”和“新游戏”是两个按钮 我有一个新的游戏功能和所有。
您能否向我提供必要的脚本,以便在单击其中一个按钮后立即关闭窗口?
【问题讨论】: