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

I have created a descendant of Tk::Toplevel which is a self-contained mini-application which I groked from a single-shot .pl script. However, try as I might, I simply cannot make this happen. My code looks sorta like this:
use Tk; use lib ... use App::Composite;
in App::Composite:
... use base qw/Tk::Toplevel/; Construct Tk::Widget 'Composite' ... implementation ...
and in test.pl
$mw = new MainWindow; $comp = $mw->Composite; $comp->resizable(0, 0); $comp->raise($mw);
It raises, but doesn't focus! Playing with $comp->focusmode and $comp->configure(-takefocus) aren't what I want! How come this isn't easy?!

Replies are listed 'Best First'.
Re: Window Focus in Tk
by dreadpiratepeter (Priest) on Aug 07, 2002 at 15:45 UTC
    $widget->focus will put the focus on a widget.
    BTW, if you haven't read Mastering Perl/Tk from O'Reilly, you should. It explains focus along with everything else Tk.

    -pete
    "Pain heals. Chicks dig scars. Glory lasts forever."
      Thanks for the pointer. Cash flow and stubbornness keep me using the predecessor book, Learning Perl/Tk by Nancy Walsh. Lots of good information, examples, and the basis for the book you mention. But no where do I see it mention '$widget->focus'.

      Thanks again,
      Brig