python tkinter 使用canvas的问题 30
def__init__(self,eventManager):self.__eventManager=eventManagerself.root=Tk()var1=Str...
def __init__(self,eventManager): self.__eventManager = eventManager self.root = Tk() var1 =StringVar() var2 = StringVar() self.root.geometry('415x320') self.root.title("login_ui") #背景图 self.canvas = tk.canvas(self.root, width=520, height=150, bg='white') img = itk.PhotoImage(file="/home/lxy/PycharmProjects/Chat_room/Chatingroom/log_head.gif") self.canvas.create_image(210, 100, image=img) self.canvas.grid(row=0, column=0, columnspan=2, padx=1, pady=3)
出错原因是
File "/home/lxy/PycharmProjects/Chat_room/chatingroom/ui/login.py", line 32, in __init__
self.canvas = tk.canvas(self.root, width=520, height=150, bg='white')
AttributeError: 'module' object has no attribute 'canvas' 展开
出错原因是
File "/home/lxy/PycharmProjects/Chat_room/chatingroom/ui/login.py", line 32, in __init__
self.canvas = tk.canvas(self.root, width=520, height=150, bg='white')
AttributeError: 'module' object has no attribute 'canvas' 展开
展开全部
如果tk是正确的tkinter模块
self.canvas = tk.Canvas(self.root, width=520, height=150, bg='white')
^大写
方法名要写对
追问
谢谢,我用pyinstaller在做尝试打包的时候因为需要用到PIL库,所以我把PIL也复制进去了,回到pycharm界面发现ImageTk报了一个Cannot find reference 'ImageTk' in '__init__.py' 错误,这个怎么解决,初学python,,不太了解
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询