【发布时间】:2017-05-12 15:13:36
【问题描述】:
我一直在尝试编写一些 python 代码,我希望根据变量的值将不同的框架“提升”到顶部。我的变量等一切正常,并且可以通过写[framename].lift() 来提升框架,但是当我尝试使框架动态时它不会工作。
我得到的错误是'str'对象没有属性。我知道它将我的动态文本视为字符串而不是命令,但我完全不知道如何让它工作。
任何帮助将不胜感激
这里是代码
class MainView(tk.Frame):
def __init__(self, *args, **kwargs):
tk.Frame.__init__(self, *args, **kwargs)
p0 = Page0(self)
p1 = Page1(self)
p2 = Page2(self)
p3 = Page3(self)
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
p0.place(in_=container, x=0, y=0, relwidth=1, relheight=1)
p1.place(in_=container, x=0, y=0, relwidth=1, relheight=1)
p2.place(in_=container, x=0, y=0, relwidth=1, relheight=1)
p3.place(in_=container, x=0, y=0, relwidth=1, relheight=1)
pt = "P"+str(seq)
pt.show()
这就是错误
File "C:/Users/gaming/Documents/MP/MP_SCL.py", line 66, in __init__
pt.show()
AttributeError: 'str' object has no attribute 'show'
【问题讨论】:
标签: python python-2.7 python-3.x tkinter