【问题标题】:TypeError: 'str' object is not callable in messgaebox of tkinter in pythonTypeError:'str'对象在python中的tkinter的messgaebox中不可调用
【发布时间】:2018-09-05 10:12:06
【问题描述】:

TypeError: 'str' 对象不可调用

执行以下代码时出现错误:

#other codes

from tkinter import *
from tkinter import ttk
from tkinter import messagebox

#othercodes

root = Tk()
frame = Frame(root)

#other codes

def net_connection_error():
    #print(dir(messagebox))
    messagebox.INFO(
        "info",
        "No Connection!"
    )

#other codes

net_connection_error()

#other codes

root.mainloop()

TypeError: 'str' 对象不可调用

【问题讨论】:

    标签: python python-3.x tkinter


    【解决方案1】:

    messagebox.INFO 是一个字符串(打印它),您将它用作函数。你想要messagebox.showinfo(...)

    注意:按照惯例,在大多数框架中,大写变量通常是字符串或数字常量。您很少会发现 INFO 可以作为函数的库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-05
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多