Boibot 发表于 2022-10-23 20:08:11

tkinter的widget Button属性Error

from tkinter import *


def click():
    print("You clicked the button!")


window = Tk()
button = window.Button(window,
                     text="click me",
                     commend=click,# callback(回调)
                     font=("Comic Sans", 30))
button.pack()

window.mainloop()

console window output:
line 10, in <module>
    button = window.Button(window,
File "C:\python\lib\tkinter\__init__.py", line 2383, in __getattr__
    return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'Button'

suchocolate 发表于 2022-10-23 20:26:18

from tkinter import *


def click():
    print("You clicked the button!")


window = Tk()
button = Button(window, text="click me", command=click, font=("Comic Sans", 30))
button.pack()

window.mainloop()

换个教程

Boibot 发表于 2022-10-23 20:45:17

suchocolate 发表于 2022-10-23 20:26
换个教程

2021年1月油兔600w播放量的教程,python3.9版本,不少属性都过时了{:10_266:}
页: [1]
查看完整版本: tkinter的widget Button属性Error