For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > September 2004 > clearing widgets embedded inside Text box and radiobutton question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author clearing widgets embedded inside Text box and radiobutton question
justme

2004-09-28, 4:11 pm

hi
i just started using Tk
i have made a left frame with some radiobuttons that is supposed to
show different widgets on a right frame whenever the user clicks on
it. For example, if user clicks on Radiobutton 1, the right frame will
display a button. I have created a Text box in the frame and embedded
the button inside this Text box.
I find that whenever i click many times on Radiobutton 1 , the button
is drawn. I only want to draw the button once whenever the user clicks
radiobutton 1, how do i do that?

another question is if the user click on Radiobutton 2, i want to
clear the button in the Text box. So far , i used destroy to destroy
the whole Text box and recreate again. I am sure there is more elegant
way of removing widgets inside a Text box. How can i remove the button
from the Text box ?
thanks
Ala Qumsieh

2004-09-29, 4:59 am

justme wrote:
> hi
> i just started using Tk
> i have made a left frame with some radiobuttons that is supposed to
> show different widgets on a right frame whenever the user clicks on
> it. For example, if user clicks on Radiobutton 1, the right frame will
> display a button. I have created a Text box in the frame and embedded
> the button inside this Text box.


Why a Text widget? Why not keep it as a frame and create the button
inside that frame? It will make life easier.

> I find that whenever i click many times on Radiobutton 1 , the button
> is drawn. I only want to draw the button once whenever the user clicks
> radiobutton 1, how do i do that?


By keeping a record of whether you created the button or not. If you
did, then simply return from the Radiobutton1 callback before you create
the button again.

> another question is if the user click on Radiobutton 2, i want to
> clear the button in the Text box. So far , i used destroy to destroy
> the whole Text box and recreate again. I am sure there is more elegant
> way of removing widgets inside a Text box. How can i remove the button
> from the Text box ?


$button->destroy;

But I have a feeling your approaching your problem from the wrong angle.
If you tell us more about your application, perhaps someone can suggest
a better approach.

--Ala

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com