composite question 
Author Message
 composite question

Quote:

> I didn't particularly like the way the check button was drawn on my
> system so I switched to using a Button, two bitmaps, and a toggle
> function to get the effect that I was looking for.  It looks really
> nice.
> Recently I decided to try my hand at making this into a composite widget
> to avoid the multiple toggle functions, and also to combine the label
> and frame that surround them into one widget.  I did this successfully
> and am pleased with the results that I was able to get using this
> method.  (Thanks for this ability...)
> My question is this.  In other composites if I use a -textvariable
> whatever widget is following the value updates it when the variable
> changes.  However, in a button situation where the variable determines
> which image is shown on the button this doesn't quite work the way I
> want.
> Is there a way to bind a function to a variable changing so that if I
> modify the variable I can get it to store the variable, but also call a
> function that will update the image on the button?

You can use tie() - Tie::Watch does this so you can set watchpoints on
variables.  In your case, create a STORE callback to change the button
image, something like this:

        use Tie::Watch;
        my $watch = Tie::Watch->new(
            -variable => \$frog,
            -store    => \&store,
        );

        ...

        sub store { # STORE callback for variable $frog

            $self->Store;   # update $frog with $new_val
            my $image = ($new_val == 1) ? $img1 : $img2;
            $button->configure(-image => $image);
        }

HTH.



Fri, 27 Jul 2001 03:00:00 GMT  
 composite question

I didn't particularly like the way the check button was drawn on my
system so I switched to using a Button, two bitmaps, and a toggle
function to get the effect that I was looking for.  It looks really
nice.

Recently I decided to try my hand at making this into a composite widget
to avoid the multiple toggle functions, and also to combine the label
and frame that surround them into one widget.  I did this successfully
and am pleased with the results that I was able to get using this
method.  (Thanks for this ability...)

My question is this.  In other composites if I use a -textvariable
whatever widget is following the value updates it when the variable
changes.  However, in a button situation where the variable determines
which image is shown on the button this doesn't quite work the way I
want.

Is there a way to bind a function to a variable changing so that if I
modify the variable I can get it to store the variable, but also call a
function that will update the image on the button?

I can provide any other information that you need to help with this
problem.  Thanks for your time.

--


-----------------------------------------
Mixed Signal Product Development EDA Team



Fri, 27 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Another Composite question

2. How to get the composite type information?

3. split composite hash key into sub key fields.

4. duplicate check of composite hash key with sub field range

5. Imagemap with Chart::Composite and GD module

6. imagemap problem with Chart::Composite module

7. Imagemap with Chart::Composite and GD modules

8. Saving state of composite data structure?

9. composite widgets tutorial

10. Exporting dynamically generated functions into a Composite widget?

11. Composite Widget with NO widgets - Possible?

12. Composite Widget ConfigSpecs METHOD problem

 

 
Powered by phpBB® Forum Software