in reply to Re^2: Tk and optionAdd's scope
in thread Tk and optionAdd's scope

optionAdd looks buggy, and I think you should just avoid it entirely. For example, it supposed to support -class, but apparently does not. If it supports -class as expected, you can simply put all 25 in the same class.

Peter (Guo) Pei

Replies are listed 'Best First'.
Re^4: Tk and optionAdd's scope
by eff_i_g (Curate) on Apr 16, 2010 at 18:50 UTC
    Eureka!

    The trick is in the path. LabFrame does not have a .font property, but its subwidget of Label does:
    use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->geometry('200x200'); $mw->optionAdd('*font', 'helvr12'); $mw->optionAdd('*LabFrame.label.font', 'helvb12'); my $lab_frm = $mw->LabFrame(-label => 'LabFrame Test')->pack; $lab_frm->Label(-text => 'Label Test')->pack; print STDERR $lab_frm->Subwidget('label')->PathName, "\n"; MainLoop;
    Update: Another interesting finding. This does not work with LabEntry because, from what I can tell, it does not advertise its Label subwidget. This can, however, be worked around by changing both subwidgets, then reverting Entry:
    $mw->optionAdd('*LabEntry*font', 'helvb12'); $mw->optionAdd('*LabEntry.entry.font', 'helvr12');