Disabling a Scale widget 
Author Message
 Disabling a Scale widget

I want to disable a Scale widget, on occasion.  I'm trying to do this
using tagConfigure and itemconfigure, but I'm not having much success.

The setup code looks like:

             $w = $frame_a->Scale(-variable     => \$ca{p_pos},
                             -length       => 650,                   # xax
                             -to           => 600,                   # xax
                             -orient       => 'horizontal',
                             -showvalue    => 0,
                             -command      => [ \&set_contig_asm_line, $canvas ]
                                 )->pack(-side => 'right');

             $w->tagConfigure('disable_in_ph2');

Later on, I expect to run some code of the form:

         $c->itemconfigure('disable_in_p2', -state => 'disabled');

I'm not getting that far, however.  On startup, I get:

   Background Error: Failed to AUTOLOAD 'Tk::Scale::tagConfigure' at ...

Help?

-r
--

http://www.*-*-*.com/ ;  - my home page, resume, etc.
http://www.*-*-*.com/ ; - The FreeBSD Browser, Meta Project, etc.
http://www.*-*-*.com/ 's DOSSIER series
http://www.*-*-*.com/ ;   - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Fri, 07 Oct 2005 09:46:00 GMT  
 Disabling a Scale widget
It appears that tagConfigure and itemconfigure simply don't work for
widgets.  This is unfortunate; I'd like to know why this is the case.

In any event, I'm able to save references to the widgets and use
configure on them, so I'm out of the swamp...

-r
--

http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Fri, 07 Oct 2005 16:44:04 GMT  
 Disabling a Scale widget

Quote:

> It appears that tagConfigure and itemconfigure simply don't work for
> widgets.  This is unfortunate; I'd like to know why this is the case.

What do you expect from tagConfigure/itemconfigure? You can do
everything with configure...

Quote:
> In any event, I'm able to save references to the widgets and use
> configure on them, so I'm out of the swamp...

Regards,
        Slaven

--

Tk-AppMaster: a perl/Tk module launcher designed for handhelds
        http://tk-appmaster.sf.net
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Fri, 07 Oct 2005 21:40:13 GMT  
 Disabling a Scale widget

Quote:
>What do you expect from tagConfigure/itemconfigure? You can do
>everything with configure...

The tagConfigure/itemconfigure API provides a set of bookkeeping
and message dispatching services which configure does not.  So, I
have to write a bit more code in the latter case.  This isn't a
big deal, but it _is_ less convenient.

Speaking of convenience, I see no convenient way to "disable" a
Label (although I'm sure I can hand-craft something that changes
the color).

This means that I have three (quite different) ways to "disable"
graphical entities.  Somehow, this isn't as OOish as I might wish.

-r
--

http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sat, 08 Oct 2005 03:31:40 GMT  
 Disabling a Scale widget

Quote:


> >What do you expect from tagConfigure/itemconfigure? You can do
> >everything with configure...

> The tagConfigure/itemconfigure API provides a set of bookkeeping
> and message dispatching services which configure does not.  So, I
> have to write a bit more code in the latter case.  This isn't a
> big deal, but it _is_ less convenient.

I can't follow you. tagConfigure is only useful in the Text widget and
itemconfigure in widgets which are composed by many smaller entities
(which are *not* subwidgets), like Canvas, HList, in Tk804 also the
plain Listbox. I don't see how the Scale widget fit into this
scheme...

Quote:

> Speaking of convenience, I see no convenient way to "disable" a
> Label (although I'm sure I can hand-craft something that changes
> the color).

> This means that I have three (quite different) ways to "disable"
> graphical entities.  Somehow, this isn't as OOish as I might wish.

Traditionally disabling in Tk means "do not accept any input for this
widget", hence it makes no sence for Label widgets. Do you mean a way
to "hide" a label?

Regards,
        Slaven

--

    Berlin Perl Mongers - http://berliner.pm.org
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sat, 08 Oct 2005 06:21:01 GMT  
 Disabling a Scale widget

Quote:
>I can't follow you. tagConfigure is only useful in the Text widget and
>itemconfigure in widgets which are composed by many smaller entities
>(which are *not* subwidgets), like Canvas, HList, in Tk804 also the
>plain Listbox. I don't see how the Scale widget fit into this
>scheme...

I have a window which has quite a few controls:

   3  Button
   4  Checkbutton
   3  Optionmenu
   3  Radiobutton
   1  Scale

Initially, everything is disabled except for two of the Optionmenus.
As the user makes selections and pushes buttons, other controls get
enabled and disabled.  Currently, I'm using a hash to store refs to
the widgets; this lets me walk through the hash to (en|dis)able the
controls, as appropriate.

If I could "tag" the controls, I could simply issue an itemconfigure
(or whatever) and change the status of a set of controls.  This would
take less code on my part.

Quote:
>Traditionally disabling in Tk means "do not accept any input for this
>widget", hence it makes no sence for Label widgets. Do you mean a way
>to "hide" a label?

When a control is disabled, any black text on the control turns grey.
This is the case for Button, Checkbutton, Optionmenu, and Radiobutton
(and probably others).  Unfortunately, the Labels that I'm putting
next to the Scale and Optionmenu cannot be "disabled", so I have to
find some other way to make them turn grey.  Otherwise, I have some
black labels sitting next to disabled controls.

This isn't so bad in the case of the Optionmenu, because the text on
the widget turns grey.  The slider, however, has no visible way of
showing that it is disabled.  It just fails to respond to the mouse.

In short, I want the visual cues to be consistent, to reduce the
user's confusion and chance for error.  It annoys me a bit that I
have to use a variety of APIs to get visually similar results.

-r
--

http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sat, 08 Oct 2005 07:54:48 GMT  
 Disabling a Scale widget
Speeking of OOish programming style:

Why don't you extend the widgets you use in a way, that they
provide a setState method, that turns their appearance and
state (if applicable) to your likes?

By the way: If you use a hash to store your widgets, you actually
_have_ a way to tag your controls. You just have to use appropriate
keys like ":tag1:tag2:actualKey:". Thus with a foreach-loop and a
simple regular expression or string index function, you are there.

If it has to be even more convenient, write your own OO-module,
that give you the special features that you want and hides all
the details.

Regards,
Gerhard



                                                    (bcc: Gerhard Petrowitsch/STN/SC/PHILIPS)                                                                      
                                                   Subject:    Re: Disabling a Scale widget                                                                        
               Rich Morin                                                                                                                                          

               Sent by:                                                                                                                                            

               .EDU                                                                                                                                                

               22-04-2003 00:21                                                                                                                                    


Quote:
>I can't follow you. tagConfigure is only useful in the Text widget and
>itemconfigure in widgets which are composed by many smaller entities
>(which are *not* subwidgets), like Canvas, HList, in Tk804 also the
>plain Listbox. I don't see how the Scale widget fit into this
>scheme...

I have a window which has quite a few controls:

   3  Button
   4  Checkbutton
   3  Optionmenu
   3  Radiobutton
   1  Scale

Initially, everything is disabled except for two of the Optionmenus.
As the user makes selections and pushes buttons, other controls get
enabled and disabled.  Currently, I'm using a hash to store refs to
the widgets; this lets me walk through the hash to (en|dis)able the
controls, as appropriate.

If I could "tag" the controls, I could simply issue an itemconfigure
(or whatever) and change the status of a set of controls.  This would
take less code on my part.

Quote:
>Traditionally disabling in Tk means "do not accept any input for this
>widget", hence it makes no sence for Label widgets. Do you mean a way
>to "hide" a label?

When a control is disabled, any black text on the control turns grey.
This is the case for Button, Checkbutton, Optionmenu, and Radiobutton
(and probably others).  Unfortunately, the Labels that I'm putting
next to the Scale and Optionmenu cannot be "disabled", so I have to
find some other way to make them turn grey.  Otherwise, I have some
black labels sitting next to disabled controls.

This isn't so bad in the case of the Optionmenu, because the text on
the widget turns grey.  The slider, however, has no visible way of
showing that it is disabled.  It just fails to respond to the mouse.

In short, I want the visual cues to be consistent, to reduce the
user's confusion and chance for error.  It annoys me a bit that I
have to use a variety of APIs to get visually similar results.

-r
--

http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 09 Oct 2005 16:33:31 GMT  
 Disabling a Scale widget

Quote:
>By the way: If you use a hash to store your widgets, you actually
>_have_ a way to tag your controls. You just have to use appropriate
>keys like ":tag1:tag2:actualKey:". Thus with a foreach-loop and a
>simple regular expression or string index function, you are there.

I'm doing something of this sort already (see below).

Quote:
>If it has to be even more convenient, write your own OO-module,
>that give you the special features that you want and hides all
>the details.

Actually, although it isn't particularly OOish, I have a function
that I call to (dis|en)able the widgets.  I hand it a hash key (for
a class of widgets) and the desired state:

     ca_config_widgets('p_ena_2', 'disabled');

The sub figures out exactly what needs to be done, using information
encoded in each widget's subsidiary key:

sub ca_config_widgets {
#
# Configure a set of widgets to a desired state.
#
# Note: For convenience, we handle "disable/enable" Labels, as well.
#
# Input:        $key            hash key for widget reference, in %ca
#               $state          desired state


     our (%ca);

     my ($color, $tmp);

     foreach $tmp (keys(%{ $ca{$key} })) {

         if ($tmp =~ m|\(Label\)$|) {

             $color = ($state eq 'normal') ? 'black'
                                           : '#a3a3a3';

             $ca{$key}{$tmp}->configure(-foreground => $color);

         } else {

             $ca{$key}{$tmp}->configure(-state      => $state);
         }
     }

Quote:
}

--

http://www.cfcl.com/rdm    - my home page, resume, etc.
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series
http://www.ptf.com/tdc     - Prime Time Freeware's Darwin Collection
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Mon, 10 Oct 2005 02:00:50 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Scale widget's callback

2. Scale widget yelling warnings

3. Scale widget not listening to -length ??

4. Non-clamping Scale widgets.

5. Scale widget command option

6. MainLoop/Scale Widget?

7. Scale Widget Problem

8. Scale widget as scroll bar possible

9. Scale widget

10. Regarding Canvas and Scale widget

11. 3-Button Scale widget?

 

 
Powered by phpBB® Forum Software