Hello, all, I'm muddling my way through building a Tk Construct for the first time, and I have a question. The object I'm making has two subwidgets, and I would like to be able to specify a different class for each of them. The way I currently have it set up, when creating the object, you'd send an arg in the hash table like this: `-classes => 'foo', 'bar'' and the first subwidget should be created with class 'foo', and the second with class 'bar'. The odd thing is that this seems to be halfway happening. The big problem seems to lie in the passive colors. An width, or activebackground color will work fine, but the default colors that appear when there is no mouse activity is always the default off-white. This is the object I've written
sub Populate { my($cw, $args) = @_; $cw->SUPER::Populate($args); my($lclass, $oclass) = @{delete $args->{'-classes'}}; my($l) = $cw->Label(-class => $lclass)->pack(-side => 'left', -fil +l => 'both', -expand => 1); my($o) = $cw->Optionmenu(-class => $oclass)->pack(-side => 'right' +, -fill => 'both', -expand => 1); $cw->Advertise('label' => $l); $cw->Advertise('optionmenu' => $o); $cw->ConfigSpecs( '-text' => [$l, undef, undef, undef], '-textvariable' => [$l, undef, undef, undef], '-options' => [$o, undef, undef, undef], DEFAULT => [SELF, undef, undef, undef] ); }
What is it that I'm doing wrong here? TIA.

In reply to 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.