设为首页 加入收藏

TOP

NameError: name 'messagebox' is not defined 错误处理
2017-09-30 17:23:38 】 浏览:7645
Tags:NameError: name ' messagebox' not defined 错误 处理

  写了段代码,想在按下button的时候跳个提示框出来,调试的时候提示了messagebox未定义

from tkinter import *

def test_show():
    messagebox.showinfo(None, 'first')
    
    
root = Tk()

one = Label(root, text = 'First')
one.pack()

two = Button(root, text = 'First', command=test_show)
two.pack()

mainloop()

 

而后在CSDN上看到有人说messagebox输入子模块,不会默认导入,然后在开头加入了messagebox的导入,程序就可以正常执行了

from tkinter import *
from tkinter import messagebox

def test_show():
    messagebox.showinfo(None, 'first')
    
    
root = Tk()

one = Label(root, text = 'First')
one.pack()

two = Button(root, text = 'First', command=test_show)
two.pack()

mainloop()

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇算法学习(一) 下一篇Python爬虫模拟登录带验证码网站

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目