Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Tk: Cannot focus in DialogBox when DynaTabFrame has page

by eff_i_g (Curate)
on Jun 19, 2009 at 15:02 UTC ( [id://773062]=perlquestion: print w/replies, xml ) Need Help??

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

Monks,

My goal is to open a DialogBox, select the content of its Entry, and focus the Entry. I'm able to do this with the following code; however, if I uncomment the add line for the DynaTabFrame it stops working.

Any ideas on how to get around this?
use warnings; use strict; use Tk; my $mw = MainWindow->new(); $mw->geometry('100x100'); my $dyna = $mw->DynaTabFrame()->pack(); #$dyna->add('test', -label => 'test'); dialog(); MainLoop(); sub dialog { my $text = 'Default'; my $dialog = $mw->DialogBox(-buttons => ['OK']); my $entry = $dialog->Entry(-textvariable => \$text)->pack(); $entry->selectionRange('0.0', 'end'); $dialog->configure(-focus => $entry); $dialog->Show(); }

Replies are listed 'Best First'.
Re: Tk: Cannot focus in DialogBox when DynaTabFrame has page
by lamprecht (Friar) on Jun 19, 2009 at 22:38 UTC
    Hi,

    You can add a line to delay focusing the dialog:

    $dialog->configure(-focus => $entry); $mw->after(250,[$dialog,'focus']); $dialog->Show();

    This works around a hardcoded 200 delay in DynaTabFrames configure handling.

    update: You could as well delay the call to &dialog using 'after'

    Cheers, Christoph
Re: Tk: Cannot focus in DialogBox when DynaTabFrame has page
by lamprecht (Friar) on Jun 20, 2009 at 07:29 UTC
      Thanks lamprecht! I used $entry instead of $dialog and got just what I was looking for.
Re: Tk: Cannot focus in DialogBox when DynaTabFrame has page
by Anonymous Monk on Jun 19, 2009 at 23:05 UTC
    Try
    $mw->Show(); # or $dyna->Show(); dialog();
      Hi,

      There is no 'Show' method in either of those widgets classes.

      Cheers, Christoph
        Hi,

        did you try? It might work if you 'raise' repeatedly until 200 ms have passed. ;)

        Cheers, Christoph
        Maybe i was thinking of raise? :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://773062]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found