Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can tile be used to create a "special" type of button?

1 view
Skip to first unread message

George Petasis

unread,
Jul 27, 2006, 2:13:54 AM7/27/06
to
Hi all,

I want to create a button similar to tile buttons, but I
want to embed a frame along with the label.

What I want to make is similar to a button that shows
an image on the left, and a label. The image has all its pixels
using the same colour. And I want to have many of these buttons.

So, I want to avoid creating so many images and having to delete them
as long as the buttons get destroyed. And since images show a fixed
colour, it would be nice if I use a tile element (a frame?)
that can be given a fixed colour. Is it possible?

I have used two approaches for doing this in the past:

1) Paint the background of the button with the colour I want. The most
efficient solution, but looks somewhat ugly and now its impossible to
use it with a tile button.

2) Used small square images, with filled with the colours I want. Its
a pretier solution, can be used with tile but many images have to be
created/deleted. And uses some memory more.

The buttons should look like:

+------------------------+
| +--+ |
| | | Label |
| +--+ |
+------------------------+

The small square will be filled with a colour.

Any ideas?

George

Uwe Klein

unread,
Jul 27, 2006, 5:12:59 AM7/27/06
to
George Petasis wrote:

>
> The buttons should look like:
>
> +------------------------+
> | +--+ |
> | | | Label |
> | +--+ |
> +------------------------+
>
> The small square will be filled with a colour.

How many _different_ colours?
>
> Any ideas?
>
> George
uwe

George Petasis

unread,
Jul 28, 2006, 6:24:54 PM7/28/06
to Uwe Klein
O/H Uwe Klein έγραψε:

~ 100-150...

George

Frank Ranner

unread,
Aug 1, 2006, 6:56:18 AM8/1/06
to
Use a monochrome bitmap of the appropriate size, and use the foreground
color attribute to color it. You can generate it directly or use an xbm
file.

regards,
Frank Ranner

Frank Ranner

unread,
Aug 1, 2006, 9:33:31 AM8/1/06
to

Have a play with this code snippet:

foreach b {0 1 2 3 4 5 6 7 8 9 a b c d e f} {
button .butt_$b -text "Button $b" -width 12
pack propagate .butt_$b off
frame .butt_$b.f -width 10 -height 10 -bg \#${b}03366
pack .butt_$b.f -side left -padx 10 -pady 5
pack .butt_$b
}

This simply puts a small frame onto the button. The pack
propagate stops the frame from resizing the button. You
can modify the appearance of the frame by playing with
the borderwidth, relief, highlight* parameters.

If you are creating lots of buttons, you may want to
consider lating them out in a text widget, as this allows
the buttons to wrap when the window size changes.

Hope this helps,

Frank Ranner

0 new messages