llancet has asked for the wisdom of the Perl Monks concerning the following question:

I'm in OpenSuse 11.0, Perl 5.10.0
I found that if you add any new widget after an Entry, you can never input any character into that Entry:
use strict; use Tk; my $mw=MainWindow->new; my $ent=$mw->Entry()->pack(); my $but=$mw->Button()->pack(); Mainloop;
By the way, I've heard that Tk works weirdly with some X11. It's that true?

Replies are listed 'Best First'.
Re: It seems that Tk has an error in some version
by zentara (Cardinal) on Oct 18, 2008 at 12:18 UTC
    I don't have your platform to test on, but it sounds like a common focus issue. Try clicking the entry with the mouse first, before typing, or do this:
    $ent->focus; MainLoop;
    Only one widget can have keyboard focus at a time, often you will see a binding like this, to ensure an entry or text widget always gets keyboard focus:
    $mw->bind( '<Any-Enter>' => sub { $ent->Tk::focus } );
    that will ensure that if your mouse wanders off of the app, the entry will regain focus when the mouse re-enters the mainwindow.

    I'm not really a human, but I play one on earth Remember How Lucky You Are
      Even on windows you have to click on the textfield to be able to type (w/original code)
Re: It seems that Tk has an error in some version
by Anonymous Monk on Oct 18, 2008 at 06:25 UTC
    Bareword "Mainloop" not allowed while "strict subs" in use
Re: It seems that Tk has an error in some version
by Anonymous Monk on Oct 18, 2008 at 06:31 UTC
    Works for me, Tk 804.027 on perl v5.8.7, and Tk 804.028 on perl v5.10.0, windows
      I know it works in windows platform. In fact, I firstly made something in ActivePerl, and while I tried to transport it into linux, I found that error.