-1

i'm using "activeforeground" in order to make it so that when i click a button the text turns "misty rose." however, i want to apply this to all the buttons in my code without combing through and changing every single one. is there a way to set this as the default "activeforeground" color? similarly to how you can change the default font of text by using this:

root.option_add("*font", "times 14 bold")

if there is an equivalent for "activeforeground" i would appreciate the help!

1 Answers1

1

The name to use with option_add isn't always exactly the same as the option used when directly configuring the widget. You need to use the "database name" which typically uses camelCase.

You can get the database name by reading the original tcl/tk documentation, or by calling the configure method on the given option. It returns a list of five items. The second item is the name to use with the option database.

In this specific case, you need to use activeForeground rather than activeforeground.

For more information on what configure returns see What are these strange options returned by the method configure?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • i am using the proper camelCase, however only the first button is being affected by the `option_add`; the rest of the buttons are still in their default, blue on click, state. should i be using something else instead of `option_add`? – user13445224 May 07 '20 at 23:00
  • 1
    @user13445224: if you want to set the default option, `option_add` is the way to do it. If you're having problems with more than one widget, you need to update your question with a proper [mcve] that illustrates that. – Bryan Oakley May 07 '20 at 23:08