以下代码在IDLE中运行正常,但我得到"NameError:全局名称'messagebox'未定义".但是,如果我明确说明from tkinter import messagebox,它可以从任何地方运行.
from tkinter import *
from tkinter import ttk
root = Tk()
mainFrame = ttk.Frame(root)
messagebox.showinfo("My title", "My message", icon="warning", parent=mainFrame)
Run Code Online (Sandbox Code Playgroud)
为什么IDLE不需要显式的import语句,但在其他地方需要它?