Takamoto has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE freezing Tk
by Corion (Patriarch) on Dec 23, 2019 at 15:37 UTC | |
by Takamoto (Monk) on Dec 23, 2019 at 15:49 UTC | |
by marto (Cardinal) on Dec 23, 2019 at 16:20 UTC | |
by Takamoto (Monk) on Dec 23, 2019 at 17:58 UTC | |
by bliako (Abbot) on Dec 24, 2019 at 10:37 UTC | |
|
Re: Win32::OLE freezing Tk
by jcb (Parson) on Dec 24, 2019 at 00:00 UTC | |
by Anonymous Monk on Dec 24, 2019 at 02:34 UTC |