Hello haj and bravo,

when I read your reply it made sense. I was surprised to read:

> Calling sleep has the same effect: It hands over control. Tk paints the screen and ... waits. It does not get any events, though. Instead, your Initialize routine wakes up and continues, happy to use the Tk screen. The program use the Tk screen drawing capability, but not the Tk event loop. So should be pack geometry manager to draw the screen.This can be reduced to:

## BAD CODE !! use strict; use warnings; use Tk; my $number = 1; my $mw = MainWindow->new; my $label = $mw->Label(-textvariable =>\$number)->pack(); # sleep 5; MainLoop; while (1){ $number++; $label->update; sleep 1;}

..without the never called MainLoop

By other hand, uncommenting the sleep 5; MainLoop; line pack does not draw the screen, so the screen drawing capability cannot be proved by me.

For sure is buggy code, but can be useful to inspect the internal machineries of Tk

The error: Tk::Label=HASH(0x39a2828) is not a Tk object at textlabel_reduced.pl line 11. only shows closing the the program with the X but no sending CTRL-C in the console.

A final note: perlmonks is the last place on earth (<- thanks to English native ;) last remaining place on earth to get support on perl Tk :)

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re^2: Basic questions of Tk programming by Discipulus
in thread Basic questions of Tk programming by jmClifford

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.