Я недавно поднял python и работаю над проектом под названием «ToDoList.py». Он закончен, но я хочу добавить кнопку, чтобы изменить тему графического интерфейса с помощью tkinter / ttk
, но она не работает.
Это ошибка:
Traceback (most recent call last):
File "todolist.py", line 64, in <module>
lbl_title = Label(root, text="ToDoList", bg="white")
File "C:\Users\Sam\AppData\Local\Programs\Python\Python37-32\lib\tkinter\ttk.py", line 761, in __init__
Widget.__init__(self, master, "ttk::label", kw)
File "C:\Users\Sam\AppData\Local\Programs\Python\Python37-32\lib\tkinter\ttk.py", line 559, in __init__
tkinter.Widget.__init__(self, master, widgetname, kw=kw)
File "C:\Users\Sam\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2296, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-bg"
Я не понимаю, почему эта ошибка возможна, поскольку я еще не настроил виджеты
from tkinter import *
from tkinter import ttk
from tkinter.ttk import *
from ttkthemes import themed_tk as tk
import random
import tkinter.messagebox
#--------root style
root = Tk()
#--------root backgroud
root.configure(bg="white")
#--------root title
root.title("Reminder")
#--------root size
root.geometry("225x300")
#--------create empty list
tasks = []
#--------fuction
def darkmd():
root.get_themes()
root.set_theme("equilux")
#--------command
lbl_title = Label(root, text="ToDoList", bg="white")
lbl_title.grid(row=0, column=0)
lbl_display = Label(root, text="", fg="black", bg="white")
lbl_display.grid(row=0, column=1)
txt_input = Entry(root, width=20, fg="black", bg="white")
txt_input.grid(row=1, column=1)
bt_add_task = Button(root, text="Add Task", fg="black", bg="white", command = add_task)
bt_add_task.grid(row=1, column=0)
bt_del_all = Button(root, text="Del all", fg="black", bg="white", command = del_all)
bt_del_all.grid(row=2, column=0)
bt_del_one= Button(root, text="Del", fg="black", bg="white", command = del_one)
bt_del_one.grid(row=3, column=0)
bt_sort_asc = Button(root, text="Sort (ASC)", fg="black", bg="white", command = sort_asc)
bt_sort_asc.grid(row=4, column=0)
bt_sort_desc = Button(root, text="Sort (DESC)", fg="black", bg="white", command = sort_desc)
bt_sort_desc.grid(row=5, column=0)
bt_total_task = Button(root, text="Num Of Task", fg="black", bg="white", command = total_task)
bt_total_task.grid(row=6, column=0)
bt_darkmd = Button(root, text="Darkmode", fg="black", bg="white", command = darkmd)
bt_darkmd.grid(row=7, column=0)
lb_tasks = Listbox(root,fg="black", bg="white")
lb_tasks.grid(row=2, column=1, rowspan=9)
#--------main
root.mainloop()