Graphic Button Question 
Author Message
 Graphic Button Question

Quote:

> I have to display  buttons that  look like there hardware counter-parts.
> The buttons are square, and devided in half.
>                                 [Image]
> If you press the button, it toggles from one state to the other.  The top
> half might have Run and if the system is running, it would be green.  If
> you press it again, it would be gray where run is and the bottom half
> would be changed to red.  I tried a bitmap, but I couldn't get red, green,
> black for the letters, and gray for the button.   Any sugestions?

How about closing the two buttons in a frame and give the
frame specific weight & height?

frame .f -height 100 -width 100
button .f.b1 -text Run  -bg green -relief flat -bd 1
button .f.b2 -text Stop -bg gray  -relief flat -bd 1
grid propagate .f 0
grid .f.b1 -sticky snew
grid .f.b2 -sticky snew
grid columnconfigure .f 0 -weight 1
grid rowconfigure .f 0 -weight 1
grid rowconfigure .f 1 -weight 1
pack .f -fill both -expand 1

The trick here is done with the command
grid propagate .f 0
which does not allow the grid packer to resize the parent
according to the space needed by the buttons. Note that
this will cause the text labels to not be shown completely
if the space of each button is small...
In the example, I have also allowed the user to resize frame
(-expand 1). You can remove it if you don't want it.

The other alternative is to emulate the buttons with
canvas objects...

hope it helps,

george



Fri, 07 Mar 2003 14:25:11 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Button graphic question

2. Graphics, Knowledge base at Icetips, Color button question

3. Graphics/Buttons on the Main Frame

4. graphic button control

5. Graphic, color button? ICE Knowledge base

6. BUTTONS--Graphic--different shapes and sizes

7. Fivewin Buttons and Bitmap Graphics

8. LPA-Prolog Buttons on a graphic window

9. Button, Button, who's got the Button?

10. button question (not a beginner question?)

11. *Now Available* Graphics on buttons & IE 3.0 styled buttons

12. A few more questions on graphics (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]

 

 
Powered by phpBB® Forum Software