G'day Evel,

"... I also want to know what the default font style name is?"

You can use the cget() method (see Tk::options) to determine the default option value of any widget.

You can find values quickly using a one-liner, e.g.

$ perl -E 'use Tk; say MainWindow->new->Listbox->cget("-background")' #d9d9d9

Some option values aren't individual scalars: you may get a reference returned, e.g.

$ perl -E 'use Tk; say MainWindow->new->Listbox->cget("-font")' Tk::Font=SCALAR(0x7f972e1bbd80)

You can just dereference as normal. Here's two examples showing the older "${ ... }", and newer "...->$*", syntaxes. See "perlref: Postfix Dereference Syntax" if you're unfamiliar with the second one.

$ perl -E 'use Tk; say ${ MainWindow->new->Listbox->cget("-font") }' Helvetica -12 bold $ perl -E 'use Tk; say MainWindow->new->Listbox->cget("-font")->$*' Helvetica -12 bold

Here's another example just to show different widgets have different defaults.

$ perl -E 'use Tk; say MainWindow->new->Text->cget("-font")->$*' Courier -12

Also be aware that, while Tk has its own defaults, these may be altered externally (e.g. a .Xdefaults file); or from within your application by a module you've loaded (e.g. a custom widget), or by your own code (e.g. one of the "option*()" methods). See Tk::option for details.

— Ken


In reply to Re^3: How to align the contents inside a ListboxSelect of Tk GUI by kcott
in thread How to align the contents inside a ListboxSelect of Tk GUI by Evel

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.