CustomTkinter
#2544
Replies: 1 comment 1 reply
-
Use Example code: from customtkinter import CTk, CTkFrame, CTkButton
global frame
def on_click():
button = frame.grid_slaves(row=0, column=0)[0]
active = True if button.cget("text") != "Stop" else False
button.configure(text="Stop" if active else "Start",
fg_color="brown" if active else "green",
hover_color="darkred" if active else "darkgreen")
if __name__ == "__main__":
app = CTk()
app.geometry("900x600")
frame = CTkFrame(app, fg_color="gray25")
frame.place(relx=0.5, anchor="center", rely=0.5, relheight=0.5, relwidth=0.5)
CTkButton(frame,
text="Start",
command=on_click,
fg_color="green",
hover_color="darkgreen").grid(row=0, column=0, padx=20, pady=20)
app.mainloop()
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
have the following problem:
I want to access a button inside a grid layout, to change its colour later in the code.
What is the best way to implement accessing the buttons from the grid?
Beta Was this translation helpful? Give feedback.
All reactions