Hello monks

I have the following basic Tk application that uses Win32::OLE to copy a PPT files to another locaction (the task is not important here, it is just to illustrate my problem). The application works fine, but it freezes for a long time, even after the OLE operation has been concluded and the message window "Done!" is shown and closed.

Can this behaviour be solved? If not, how can I show my message "Done!" only after the GUI is reactive? The problem is that the user thinks s/he has control over the GUI as soon as the "Done!" message is shown.

Furthermore: shouldn't $ppt->{Visible} = 0; prevent the PowerPoint application to show up?

use strict; use warnings; use utf8; use Tk; use Try::Tiny; use Win32::OLE; use Win32::OLE::Const qw( Microsoft.PowerPoint ); use Win32::OLE::Enum; my $mw = Tk::MainWindow->new( -width => 160, -height => 120, ); $mw->packPropagate(0); # Button erstellen: my $but = $mw->Button( -text => "Save PPT", -command => \&save_PPT, ); $but->pack(); my $quit_btn = $mw->Button( -text => "Exit", -command => \&quit_program, ); $but->pack(); $quit_btn->pack(); $mw->MainLoop(); sub save_PPT { my $filename = "C:\\Users\\Taka\\Desktop\\original.pptx"; my $ppt; try { $ppt = Win32::OLE->GetActiveObject('PowerPoint.Application') + } catch { die $_ } ; unless ( $ppt ) { $ppt = Win32::OLE->new( 'PowerPoint.Application', sub { $_[0]->Quit } ) or return 'error'; } $ppt->{Visible} = 0; my $presentation = $ppt->Presentations->Open($filename, 1); my $slides = Win32::OLE::Enum->new( $presentation->Slides ); $presentation->SaveAs("SAVED_" . $filename); $presentation->Close; $mw->messageBox (-title => "message", -message=>"DONE!", -icon=> 'info +'); } sub quit_program { exit(0); }

Any suggestion would be very much appreciated.


In reply to Win32::OLE freezing Tk by Takamoto

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.