所以我有一个简单的showinfo
,当我单击确定按钮时,我想在控制台上打印一些内容。我知道您会用askyesno
框这样做。
def show_warning(self):
self.startbutton.config(state="active")
message_box = messagebox.askyesno("Break reminder","Remember, your breaks should ideally be between 3-5 minutes.")
if message_box == 'yes':
print("Yes clicked")
else:
print("No clicked")
当消息框为showinfo()
时该怎么办?
答案 0 :(得分:2)
showinfo()
信息框仅允许用户在关闭对话框后继续使用tk应用程序。您可以使用它来确定他们是否单击了“确定”,就像askyesno()
:
def show_warning(self):
self.startbutton.config(state="active")
Msg = "Remember, your breaks should ideally be between 3-5 minutes."
if messagebox.showinfo("Break reminder", Msg):
print("Ok clicked")
#rest of the program can now continue
即无需检查是否没有单击“确定”