Interesting.. Can you show a simple version of your code?

Maybe there is something amiss in the button callback? I mean if you are doing something like this:

$detailLog->insert ('end', $_); # or $detailLog->insert ('end', $string);
Then,
$detailLog->delete("1.0", 'end');
will work...there may be some apparently minor looking syntax error in your code that is causing problems.

Update: A simple text window with "clearing the text" button is shown below. A couple of other Tk options are also demo'ed. I use 'ROText' instead of 'Text' to show that this is "Read Only". Try it!

This "enable" and "disable" stuff will usually be ok, but there will be a short interval of time where the user can modify the displayed window.

I have one application where I just don't care whether or not the user modifies the text window and I don't use ROText. I'm not reading that result and modifying the database. The user can add notes, and formatting characters before doing a "copy and paste" to another application. Fine with me!

Anyway, what is the problem with $detail_log->delete("1.0", 'end');?

#!/usr/bin/perl -w use strict; use Tk; use Tk::Frame; #optional - may be needed for an .exe use Tk::ROText; #optional - may be needed for an .exe my $mw = MainWindow->new; my $f_menu_dialog = $mw->Frame()->pack(-side=>'top',-fill=>'x'); $f_menu_dialog->Button( -text =>"Clear All text", -command => \&Clear_all_text, )->pack(-side=>'left'); my $f_text = $mw->Frame( -relief => 'groove', -borderwidth => '4', )->pack ( -expand => 1, -side => 'top', -fill => 'both', ); my $detail_log = $f_text->Scrolled('ROText', -scrollbars => 'e')->pack; foreach ("blah\n", "more blah\n", "yet more blah\n") { $detail_log -> insert('end', $_); } MainLoop(); sub Clear_all_text { $detail_log->delete("1.0", 'end'); }

In reply to Re^3: tK Scrolled Questions? by Marshall
in thread tK Scrolled Questions? by kgnickl

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.