use Tk; use lib '/genesis/oscripts/misc_scr/lib'; use OwegoCAM::GUI::GUIBuilder::LabelOption; my($mw) = MainWindow->new; my($fileloc) = "/genesis/oscripts/misc_scr/lib/OwegoCAM/GUI/GUIBuilder +/.Xdefaults.ocd"; $mw->optionReadfile($fileloc) if (-e $fileloc); my(%foo) = ('bar' => [qw/yes no maybe/]); my($bah) = $mw->LabelOption(-class => 'Lab2', -options => $foo{'bar'}, -label => 'Is it safe?', -labelPack => [-side => 'left'] )->pack(); MainLoop;
And here's an excerpt from the .Xdefaults:
*Lab2*optionmenu*activeForeground:#000000 *Lab2*optionmenu*activeBackground:tan3 *Lab2*optionmenu*background:tan3 *Lab2*optionmenu*font:-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*- +* *Lab2*optionmenu*foreground:#000000 *Lab2*optionmenu*relief:raised *Lab2*optionmenu*cursor:right_ptr *Lab2*optionmenu*width:15 *Lab2*optionmenu*anchor:w *Lab2*label*background:wheat1 *Lab2*label*font:-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-* *Lab2*label*foreground:black *Lab2*label*relief:flat *Lab2*label*width:15 *Lab2*label*anchor:w
The only thing that actually gets a color set is the option menu background when the mouse is over it, and the optionmenu's width. Thanks, -Peter Oh, sorry. Rereading the original post, I've since changed the original module that I was using. The Tk widget code now looks like this (mostly lifted from Mastering Perl/Tk):
package LabelOption; use Tk::widgets qw /Optionmenu/; use base qw/Tk::Frame/; use strict; Construct Tk::Widget 'LabelOption'; sub ClassInit { my($class, $mw) = @_; $class->SUPER::ClassInit($mw); } sub Populate { my($self, $args) = @_; $self->SUPER::Populate($args); my($o) = $self->Optionmenu->pack(); $self->Advertise('optionmenu' => $o); $self->ConfigSpecs('DEFAULT' => [$o]); $self->Delegates('DEFAULT' => $o); } 1;

In reply to Re^2: Specifying the -class of Tk subwidgets by monksp
in thread Specifying the -class of Tk subwidgets by monksp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.