Python 属性错误:';显示';对象没有属性';获取';在Tkinter中使用类时

Python 属性错误:';显示';对象没有属性';获取';在Tkinter中使用类时,python,tkinter,Python,Tkinter,嗨,我想在tkinter中获取用户数据,在一个类中,我编写了一些函数,稍微短一点,一切都很好,但当我想从用户那里获取数据时,它会给我带来我在标题中提到的错误 class Show: def __init__(self,WindowName=None, place_x=None, place_y=None): self.WindowName = WindowName self.place_y = place_y self.place_x =

嗨,我想在tkinter中获取用户数据,在一个类中,我编写了一些函数,稍微短一点,一切都很好,但当我想从用户那里获取数据时,它会给我带来我在标题中提到的错误

class Show:
    def __init__(self,WindowName=None, place_x=None, place_y=None):
        self.WindowName = WindowName
        self.place_y = place_y
        self.place_x = place_x
    def entry(self):
        global ent
        ent = Entry(self.WindowName)
        ent.place(x=self.place_x, y=self.place_y)
然后我编写了一个函数来使用这个类:

def AutoLoginPage():
    ent0 = Show(WindowName=window, place_x=90, place_y=60)
    ent0.entry()
    ent0.get()
在最后一行中,编译器给出了以下错误:

ent0.get()
AttributeError: 'Show' object has no attribute 'get'

谢谢大家的帮助

你有没有列出一些条目?如果是,请尝试ent[0}.get(),很明显,
Show
对象没有名为
get
的方法。错误告诉了您真相。它不是编译器,而是解释器。根据您的代码,
ent0.get()
应该是
ent.get()
as
ent
是在
Show.entry()
函数中创建的全局变量。@acw1668不幸的是,它不适用于