in reply to Help with Tk::BrowseEntry

Hi Bloodelf,

Want a brute-force way to do this? It may be ugly, but it will set the font of any grandchildren of the window to a font you specify.

Please don't use this as is and instead refine it to minimally suit your needs. I just want to give you some ideas. Uncomment the print statements to see the widgets you are operating on.

#! /usr/local/bin/perl -w use strict; use Tk; use Tk::BrowseEntry; # Create the main window my $w; $w->{main} = MainWindow->new; # Create the browse entry $w->{be} = $w->{main}->BrowseEntry( -label => "be" )->pack; $w->{be}->insert("end", "opt1"); $w->{be}->insert("end", "opt2"); $w->{be}->insert("end", "opt3"); # Make a font my $font = $w->{main}->fontCreate('myfont', -family => 'Helvetica', -s +ize => 20); # Assign it to the widget $w->{be}->configure(-font=> 'myfont'); # Find all the children of the browse entry. foreach ($w->{be}->children) { #print "$_\n"; # find all the grandchildren and assign them a new font. foreach ($_->children) { #print "\t$_\n"; if ($_->cget('-font')) { $_->configure(-font => 'myfont'); } } } MainLoop;
Good luck,
{NULE}
--
http://www.nule.org

Replies are listed 'Best First'.
Re: Re: Tk::BrowseEntry
by Bloodelf (Beadle) on Mar 26, 2002 at 13:40 UTC
    Many thanks - This code will also come in useful for loads of other stuff too.