G'day zentara,

"Doesn't $textbox->delete(0, "end") work?"

Whilst that is valid syntax, the OP hasn't written his code to take advantage of it. Instead of a Perl widget handle like $textbox, a Tcl pathname, like '.c.textbox', has been used. As per "Calling Tcl and Tk Commands", the required syntax would need to be the rather clunky:

Tkx::i::call('.c.textbox', 'delete', 0 => 'end');

Given the way the OP's code has been written, I think huck's solution of assigning empty strings is a better option. Unless I wanted to target just a portion of the displayed text, I'd probably choose variable modification over accessing an index-based range.

Having said that, the OP's code has many problems, not least of which is the monolithic approach, with global variables just springing into existence without any regard for their scope. I wouldn't have written it like that to start with; in fact, the method described in the Tkx::Tutorial's section "Subclassing Tkx::widget" is a small amount of up-front work but results in much shorter, and easier to read, GUI code. Instead of code like:

Tkx::ttk__entry(".frame.textbox", ...); Tkx::grid(".frame.textbox", ...); ... Tkx::i::call('.frame.textbox', 'function', ...);

You can write something closer to:

my $textbox = $frame->entry(...)->grid->(...); ... $textbox->function(...);

Even with something as simple as the OP's GUI (5 entry, 5 label and 2 button widgets), the reduction in the amount of GUI code that needs to be written, and the improved readability, is clear.

— Ken


In reply to Re^2: Tkx and clear a textbox content by kcott
in thread Tkx and clear a textbox content by jasonwolf

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.