python 属性错误:模块'customtkinter'没有属性'set_appearance_mode'

31moq8wy  于 2022-12-10  发布在  Python
关注(0)|答案(1)|浏览(77)

模板代码出错。错误:

customtkinter.set_appearance_mode("System")  # Modes: system (default), light, dark
AttributeError: module 'customtkinter' has no attribute 'set_appearance_mode'

编码:

import customtkinter

customtkinter.set_appearance_mode("System")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue")  # Themes: blue (default), dark-blue, green

app = customtkinter.CTk()  # create CTk window like you do with the Tk window
app.geometry("400x240")

def button_function():
    print("button pressed")

# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(master=app, text="CTkButton", command=button_function)
button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)

app.mainloop()

我在PyCharm中使用了python 3.7版。

m1m5dgzv

m1m5dgzv1#

这段代码看起来不错。也许你有这个库的旧版本。你可以尝试更新你所有的模块:
第一个

相关问题