Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Block Tk GUI while doing a process

by Anonymous Monk
on Jun 30, 2019 at 16:25 UTC ( [id://11102187]=perlquestion: print w/replies, xml ) Need Help??

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

Dear monks

I am pretty sure there is a built-in solution for the feature I am searching. What is the best way to take the focus out of an entire Tk GUI while I am eating that a process (download) is terminated. While downloading the file, my GUI remains responsive (which in many cases is fine), but in my particular case I do want the user to wait for the download to be completed before s/he can do something with the GUI.

Replies are listed 'Best First'.
Re: Block Tk GUI while doing a process
by haukex (Archbishop) on Jun 30, 2019 at 16:41 UTC
Re: Block Tk GUI while doing a process
by Discipulus (Canon) on Jul 01, 2019 at 08:49 UTC
    > What is the best way to take the focus out of an entire Tk GUI while I am eating that a process (download) is terminated..

    If I have not misunderstood your question, I think you can play with: $window->focus and iconify deiconify raise or withdraw and state (to query the current state) all methods of Toplevel methods.

    An example available here

    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.
Re: Block Tk GUI while doing a process
by kcott (Archbishop) on Jul 01, 2019 at 07:37 UTC

    Take a look at Tk: Binding Events and Callbacks. Your post is a bit sketchy on details, making a definitive answer difficult; however, Tk::after and Tk::fileevent look to be likely candidates for what you might want; other items in that section may also be useful.

    I've written a number of posts over the years which may be relevant to your needs. In many cases I've included fully working scripts. There may be something there to suit your needs or which you can adapt as necessary. You can use this preloaded search (if you're unfamiliar with Super Search, that just preloads the search parameters: click "Search" to get the results).

    — Ken

Re: Block Tk GUI while doing a process
by Anonymous Monk on Jul 01, 2019 at 01:06 UTC

    $mw->Busy;

    $mw->Unbusy;

    Although, by default the GUI shouldn't be responsive while downloading

Re: Block Tk GUI while doing a process
by nikosv (Deacon) on Jul 01, 2019 at 16:34 UTC
    >While downloading the file,my GUI remains responsive what do you mean? is the downloading happening in another thread? if not, isn't the downloading blocking the main/GUI thread?
Re: Block Tk GUI while doing a process
by Anonymous Monk on Jul 01, 2019 at 21:06 UTC

    Thank you for the suggestions! The GUI does remain reactive because I use $mw->update; while downloading the file in order to update a Progressbar.

    I opted for a quite easy solution which shows a top window with a grab until the download process is completed.

    my $tl = $mw->Toplevel( -title => 'WAIT' ); $tl->resizable( 0, 0 ); $tl->transient($tl->Parent->toplevel); $tl->protocol('WM_DELETE_WINDOW' => sub {}); $tl->grab; my $image_file = "wait.jpg"; my $splashphoto = $tl->{Photo} = $tl->Photo(-file => $image_file); $tl->Label(-image => $splashphoto, -bd => 0)->pack(-fill => 'both' +, -expand => 1);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found