I am creating a program using Python and Gtk. I want to guide the user by pointing out mistakes if any. I have attached a sample glade interface below. Here the user is supposed to enter a valid station name in the GtkEntry field. I want to highlight this field with red color (for instance) if he presses the submit button.
How do I achieve this in GTK3 with Python?
First, you will need the
Color
class fromGdk
and theGtk
class:Then, in your handler, change the foreground color of the text field:
If you want to change the color back to the default when the text field is modified, put this in the change handler:
The RBG values for the
Color
class are in a range from 0-65535.For more information, see the PyGTK documentation, specifically the Widget and Color classes.