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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |