Adam Cunningham wrote:
> Hi, I was hoping someone may be able to help me on an issue I'm having
> with Tkinter buttons; or more specifically, the background and
> foreground settings.
> 
> I've created a program that is supposed to simulate an order system: the
> first section (frame) is where the user adds items to the order and the
> second section (frame) is where payment is processed. The second section
> only activates when the first section has been confirmed by the user; so
> in the meantime all buttons in the second section are disabled. They are
> then activated so the user can complete the transaction and the first
> section is disabled so the order can't be edited during payment.
> 
> It all seems to be working great except that when a button is
> 'activated' its appearance loses its foreground and background
> properties, appearing with the default greyish background and black
> font.. As soon as the mouse hovers over the buttons the colour corrects
> itself.

A Button (and most other widgets) has three `state`: "normal"
(clickable), "active" (mouse hover), and "disabled". "active" in Tk's
sense means you hover your mouse on the button, not making the button
clickable (which is the "normal" state).

These are the properties of a button:
 |      STANDARD OPTIONS
 |
 |          activebackground, activeforeground, anchor,
 |          background, bitmap, borderwidth, cursor,
 |          disabledforeground, font, foreground
 |          highlightbackground, highlightcolor,
 |          highlightthickness, image, justify,
 |          padx, pady, relief, repeatdelay,
 |          repeatinterval, takefocus, text,
 |          textvariable, underline, wraplength
 |
 |      WIDGET-SPECIFIC OPTIONS
 |
 |          command, compound, default, height,
 |          overrelief, state, width

You need to change the `background` property to a color of your choosing
instead of the `activebackground`. `activebackground` is for background
color when the button is hovered.

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to