Python Tkinter属性E

2024-06-10 22:31:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我制作了一个tkinter程序,不断出现以下错误:

File "F:\Programming 2\Gui\Gui #11.py", line 78, in shape_workit
cylinder(pos=(0,0,0),axis=(1,0,0),color=self.color3.get(),

AttributeError: 'Kinter' object has no attribute 'color3'

以下是发生错误的代码:

def shapescolor(self):
    if self.color1.get()=="Does a Orange":
        color3=color.orange
    if self.color1.get()=="Does a Blue":
        color3=color.blue
def shape_workit(self):  
    try:
        if self.shape.get()=="Does a Cylinder":                         #Creates Cylinder
            cylinder(pos=(0,0,0),axis=(1,0,0),color=self.color3.get() ##ERROR HERE,
                     radius=float(self.radius.get()))

下面是错误的来源代码


Tags: posselfgetifdef错误guicolor
1条回答
网友
1楼 · 发布于 2024-06-10 22:31:20

我的猜测是您需要执行self.color3 = ...而不是color3 = ...,因为您稍后引用了self.color3,并且在发布的代码中没有在其他任何地方设置该属性

相关问题 更多 >