CustomTkinter
CustomTkinter copied to clipboard
Change default colour scheme on button click
I want to change the default colour scheme on the click of a button. When I click on the button to change colour, a function gets called which is meant to update the default colour scheme, however this does not work. Any ideas why? Find my code below.
import tkinter as tk
import customtkinter
window = customtkinter.CTk()
window.geometry("1900x980")
mainFrame = customtkinter.CTkFrame(window, width=1900, height=980)
mainFrame.pack()
mainFrame.pack_propagate(0)
loginButton = customtkinter.CTkButton(master=mainFrame, text="Login", width=350, height=45, corner_radius=10)
loginButton.pack(padx=7, pady=5)
def changeColour():
customtkinter.set_default_color_theme("green")
greenButton=customtkinter.CTkButton(master=mainFrame, height=30, width=60, text="", fg_color="green", command=changeColour).place(x=20, y=90)
window.mainloop()