简体   繁体   English

tkinter.messagebox 之后如何进入

[英]How after tkinter.messagebox then entry

ready = tkinter.messagebox.askyesno("Guess", "Are you ready?")

def func():
    entry = Entry(windows,bg = "lightblue")
    entry.pack()

if ready == False:
    windows.quit()
else:
    func()

I just start learn tkinter and try to practice it.我刚开始学习 tkinter 并尝试练习它。 When i do the messagebox, i could'n entry anything in the box.当我做消息框时,我无法在框中输入任何内容。 How could I fix it, thank you very much.怎么解决,非常感谢。

I guess you can't use tkinter.messagebox directly.我猜你不能直接使用tkinter.messagebox But if you import this, you will face no issue.但是,如果您导入它,您将不会遇到任何问题。 I have just made a little modification to your code and now it's working fine.我刚刚对您的代码进行了一些修改,现在它工作正常。

import tkinter
import tkinter.messagebox as message

windows = tkinter.Tk()
ready = message.askyesno("ready?")
#print(ready)
def func():
    e = tkinter.Entry(windows, bg="lightblue")
    e.pack()

if ready == False:
    windows.quit()
else:
    func()
windows.mainloop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在此代码中获取 tkinter.messagebox 的名称条目? - How can I get the name's Entry for tkinter.messagebox in this code? tkinter.messagebox中的“ For”循环? - “For” loops within a tkinter.messagebox? showinfo 和 showwarning 出现在 tkinter.messagebox 的背景中 - showinfo and showwarning appearing in the background in tkinter.messagebox 为什么导入tkinter之后,我需要导入tkinter.messagebox但不需要导入tkinter.Tk()? - Why do I need to import tkinter.messagebox but don't need to import tkinter.Tk() after importing tkinter? Python - tkinter.messagebox 在 macOS 中看不到标题和显示错误图标 - Python - tkinter.messagebox cannot see title and showerror icon in macOS “if”语句用于显示错误 tkinter.messagebox 不起作用 - "if" statement used to display an error tkinter.messagebox is not working 导入 tkinter 的“messagebox”模块时,“import tkinter.messagebox”语法是否不起作用? - When importing tkinter's “messagebox” module, does the “import tkinter.messagebox” syntax not work? Tkinter 消息框导致 Entry 禁用 - Tkinter Messagebox causing Entry to disable Python Tkinter使用输入字段创建MessageBox - Python Tkinter Use Entry Field to Create MessageBox tkinter 消息框阻止条目小部件工作 - tkinter messagebox prevents Entry widget from working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM