我的代码导致了一个错误。它表示syntaxerror:无法分配函数调用。我正在windows 10上使用IDLE。以下是导致错误的代码:
from tkinter import *
from tkinter.Ttk import *
import sys
root = Tk()
class Label:
def __init__(self, txt, fomtsize, fomtype, hhexx_fg, borderstate, hhexx_bg_truestate, hhexx_bg, yex_pos, why_pos, bordr, masta, hght, wdth, xp, yp):
if ((hhexx_bg_truestate == False) and (borderstate == False)):
Label(master=masta, textvariable=str(txt), font=(float(fomtsize), str(fomtype)), fg=str(hhexx_fg), height=(int(hght)/2), width=(int(wdth)/2)), padx=xp, pady=yp).place(height, width = hght, wdth, x, y = yex_pos, why_pos)
self.text = txt
self.size = fomtsize
self.font = fomtype
self.color = hhexx_fg
self.x_position = yex_pos
self.y_position = why_pos
self.border = bordr
self.height = hght
self.width = wdth
elif ((hhexx_bg_truestate == True) and (borderstate == False)) :
Label(bg=hhexx_bg, master=masta, textvariable=str(txt), font=(float(fomtsize), str(fomtype)), fg=str(hhexx_fg), height=(int(hght)/2), width=(int(wdth)/2)), padx=xp, pady=yp).place(height, width = hght, wdth, x, y = yex_pos, why_pos)
self.text = txt
self.size = fomtsize
self.font = fomtype
self.color = hhexx_fg
self.x_position = yex_pos
self.y_position = why_pos
self.border = bordr
self.height = hght
self.width = wdth
elif ((hhexx_bg_truestate == False) and (borderstate == True)) :
Label(bd=bordr, master=masta, textvariable=str(txt), font=(float(fomtsize), str(fomtype)), fg=str(hhexx_fg), height=(int(hght)/2), width=(int(wdth)/2)), padx=xp, pady=yp).place(height, width = hght, wdth, x, y = yex_pos, why_pos)
self.text = txt
self.size = fomtsize
self.font = fomtype
self.color = hhexx_fg
self.x_position = yex_pos
self.y_position = why_pos
self.border = bordr
self.height = hght
self.width = wdth
elif ((hhexx_bg_truestate == True) and (borderstate == True)) :
Label(bg=hhexx_bg, bd=bordr, master=masta, textvariable=str(txt), font=(float(fomtsize), str(fomtype)), fg=str(hhexx_fg), height=(int(hght)/2), width=(int(wdth)/2)), padx=xp, pady=yp).place(height, width = hght, wdth, x, y = yex_pos, why_pos)
self.text = txt
self.size = fomtsize
self.font = fomtype
self.color = hhexx_fg
self.x_position = yex_pos
self.y_position = why_pos
self.border = bordr
self.height = hght
self.width = wdth
(我知道我可以改进我编写类的方式,我浪费了很多行,并且没有使用最佳实践。)
在代码中,函数调用被分配到哪里?以前我在课堂上写过:
self.label = Label(...)
那我就能理解错误了。我正在给某个东西分配标签函数。但这一次,我纠正了这一点!为什么会出现错误
您必须擦除宽度处的
)
因此正确的字符串如下所示:
您还必须重命名类,因为tkinter已经使用了
Label
或
最后你必须看看你的
.place()
方法。我不确定哪个参数的值,所以你必须纠正这个问题相关问题 更多 >
编程相关推荐