【发布时间】:2021-07-11 11:20:55
【问题描述】:
我正在尝试在某个操作完成后弹出一条消息,但确定按钮不起作用。
def delete_all_songs():
if messagebox.askokcancel("Delete all Songs","Are you sure you want to delete all Songs"):
print("doing")
filelisttodelete = [f for f in os.listdir("C:/MusicPlayer/Songs/") if f.endswith(".mp3")]
for f in filelisttodelete:
os.remove(os.path.join("C:/MusicPlayer/Songs/", f))
songs_box.delete(0, END)
pygame.mixer.music.stop()
else:
pass
【问题讨论】:
-
当您单击
Cancel时,它会返回False。你试过打印吗? -
什么意思
-
如果我点击确定按钮没有任何反应。
-
x=messagebox.askokcancel("Delete all Songs","Are you sure you want to delete all Songs"),print(x) -
对我来说效果很好,单击“确定”按钮时控制台中会显示“正在执行”。
标签: python tkinter popup messagebox