Frandajo has asked for the wisdom of the Perl Monks concerning the following question:

Dear Learned Ones,

I have a Tk application for an on-line, 3D, RP game that monitors the users avatar. One of the features is to set body scale. I would like a range from 0.01 to 9.99 but with 1.00 in the center...not crowded to the left 10%, where it would not make sense.

A logarithmic sort of Tk::Scale widget is needed. Surely I am not the first to desire such. I cannot imagine it does not exist. Yet I cannot find it.

I am currently making do with radiobuttons in discrete intervals. But this is really kind of clunky. Any directions toward where in Perl/Tk such a widget is to be found would be most appreciated.

Thanks bunches,

Fran

Replies are listed 'Best First'.
Re: A logarithmic Tk:Scale widget?
by graff (Chancellor) on Dec 09, 2007 at 20:21 UTC
    While you're waiting for the LogScale widget to show up on CPAN, you could experiment with offering the user a simple linear scale that controls the exponent to be applied to your avatar's body scale. Here's a stripped-down example of what the might look like:
    #!/usr/bin/perl use Tk; $m=MainWindow->new(-title => "test"); $m->Button(-command => sub{exit(0)}, -text => "Bye")->pack; my $scale_value_str = " current scale value = "; $m->Label(-textvariable => \$scale_value_str)->pack; $m->Scale(-from => -2, -to => 2, -digits => 0, -resolution => -1, -command=>sub{$scale_value_str=sprintf " current scale = %8. +3f ",10**$_[0]} )->pack; MainLoop;
    (updated to show the resulting scale value in the Tk window, rather than on stdout)
Re: A logarithmic Tk:Scale widget?
by eserte (Deacon) on Dec 09, 2007 at 19:15 UTC
    I have a Tk::LogScale widget available. Shall I release it to CPAN?
      Yes, please.
        It's on the way...
        The uploaded file
        
            Tk-LogScale-0.08.tar.gz
        
        has entered CPAN as
        
          file: $CPAN/authors/id/S/SR/SREZIC/Tk-LogScale-0.08.tar.gz
          size: 4706 bytes
           md5: d779f93b739583495c4c784d0e6a209d
        
        No action is required on your part
        Request entered by: SREZIC (Slaven ReziÄ<87>)
        Request entered on: Sun, 09 Dec 2007 20:31:58 GMT
        Request completed:  Sun, 09 Dec 2007 20:32:33 GMT
        
Re: A logarithmic Tk:Scale widget?
by johngg (Canon) on Dec 09, 2007 at 18:16 UTC
    If I remember my schoolboy maths correctly, using a logarithmic scale with the range you give will result in the 1 being a little way towards the right, not in the centre. If you could modify your range to have a minimum of 0.1 rather than 0.05 you would be allright. I'm afraid I can't point you to a suitable widget, my Tk experience is not much beyond baby steps.

    Cheers,

    JohnGG

      Yes, of course. Thank you so much for that, entirely correct observation. It remains wholly unhelpful, though, as you yourself did observe.