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
>
> The buttons should look like:
>
> +------------------------+
> | +--+ |
> | | | Label |
> | +--+ |
> +------------------------+
>
> The small square will be filled with a colour.
How many _different_ colours?
>
> Any ideas?
>
> George
uwe
~ 100-150...
George
regards,
Frank Ranner
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