Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Tk - Tick box size change

by merrymonk (Hermit)
on Mar 13, 2019 at 14:32 UTC ( [id://1231230]=perlquestion: print w/replies, xml ) Need Help??

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

Although I have used Perl Tk for a number of years I never have wanted to do this before.
I want to alter both the size of the tick box in a Checkbutton and the size of the round button of a Radio button.
I could not see any obvious option for this so I thought it may be affected my the text size on the widget.
The Perl below creates 2 Checkbuttons with different sizes of text. However the tick boxes are the same size.
Is there a way of altering the tick box size? I could want differenmt sizes on various widgets.
use Tk; use strict; my $mw = MainWindow->new(-title => 'CheckBox size'); my $f = $mw->Frame->pack(-side => 'top'); my $weight = "normal"; my $fch = $f->Checkbutton( -text => "Weight", -variable => \$weight, )->pack(-side => 'left'); my $size = 16; $fch->configure(-font => [ -size => $size ]); my $fch2 = $f->Checkbutton( -text => "Weight", -variable => \$weight, )->pack(-side => 'left'); $size = 32; $fch2->configure(-font => [ -size => $size ]); MainLoop;

Replies are listed 'Best First'.
Re: Tk - Tick box size change
by Lotus1 (Vicar) on Mar 13, 2019 at 19:06 UTC

    Your options seem to be either to supply your own images for the checked and unchecked checkboxes to Checkbutton or use a different checkbutton object. I found Tk::Checkbox has the option of setting the size. I don't see how to add text next to it so you likely will need to add your own label.

    use warnings; use strict; use Tk; use Tk::Checkbox; my $mw = MainWindow->new(-title => 'CheckBox size'); my $f = $mw->Frame->pack(-side => 'top'); my $weight1 = "normal"; my $fch = $f->Checkbutton( -text => "Weight", -variable => \$weight1, )->pack(-side => 'left'); my $size = 16; $fch->configure(-font => [ -size => $size ]); my $weight2 = "Weight"; my $fch2 = $f->Checkbox( -variable => \$weight2, -command => sub {print "$weight2\n"}, -onvalue => "Weight", -offvalue => "Mass", -size => 25, )->pack(-side => 'left'); MainLoop;

    I found it was tricky to install Tk::Checkbox in CPAN since install Tk::Checkbox doesn't work and i /Tk::Checkbox/ doesn't find anything. I had to use install MIKRA/Tk-MK-0.23.tar.gz.

      Thank you. I was hoping it would have been more straightforward however, I will try and use what you have suggested.

        It looks like you can also place buttons on a canvas and then scale the canvas. I don't have time to dig into this and there are monks around who are experienced with Perl/Tk who might be able to provide an example.

        Edit: Here is a Perlmonks node that deals with scaling canvases but not really scaling buttons. It might give you something to go on.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1231230]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-24 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found