Ruby/Tk: How to specify default background colour

R

Ronald Fischer

I find the default colour assignment for Tk widgets (kind of a dark-green over a something I could best describe a muddy brown) a bit
difficult to read, and therefore would like to use a different
background colour for my widget.

In my first attempt, I just assigned a new background colour to the
TkRoot object, but this colour information is not inherited by the
child widgets. Of course I can, for each child widget, explicitly
configure the background colour, but I wonder whether there is
maybe an easier way to do this.
 
R

Ronny

Ronald said:
I find the default colour assignment for Tk widgets (kind of a dark-green over a something I could best describe a muddy brown) a bit
difficult to read, and therefore would like to use a different
background colour for my widget.

I found the solution! Here is how I did it:

Before entering the main loop, I use the statements

$dft_background="#F8E8EE"
TkOption.add("*foreground","blue")
TkOption.add("*background",$dft_background)

Then, when creating the root widget, I write

TkRoot.new() { background $dft_background }

This together has the desired effect.

Ronald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top