I think there is a way to check how wide a text is using a particular font - but I don't have my Tk books here so I can't check. I might be totally wrong.

There might however be a simpler solution that does what you want. Try aligning your text in the button. By default, Tk will center text (and hence, if the widget is too small, only display the center part). If you tell Tk to put the text on the left, it will show the left part of the text if it gets clipped. Unfortunally, this has the drawback that if the text is smaller than the button, it won't be centered. If that's not what you want, disregard this suggestion.


In reply to Re: Size of text in perlTk button by Anonymous Monk
in thread Size of text in perlTk button by blueberryCoffee

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.