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

I wish to pop up a progress dialog for a windowless app. Is there any way to do this? I've been doing this...
use base qw(Wx::ProgressDialog); sub new { my $class = shift; my $max = shift || 10; my $vars = (wxPD_CAN_ABORT| wxPD_APP_MODAL|wxPD_ELAPSED_TIME| wx +PD_ESTIMATED_TIME| wxPD_REMAINING_TIME); my $this = $class->SUPER::new("xp6 progres ($max)", "the progres +s ($max)", $max, undef, $vars); $this->Show(1); return $this; }

Oddly, when I send it updates, it doesn't show up but when I max it out with the last Update(), it suddenly shows up (completed).

I'm guessing it's not showing up because the parent window paramater is undef, but what I'm wondering is if there's a way to pop up a progress dialog without a parent window?

Incidentally, I got this invocation from 215789 and using that example, the dialog definitely works. I'm just trying to do it without the parent window.

Replies are listed 'Best First'.
Re: Wx::ProgressDialog, please help
by PodMaster (Abbot) on Jul 27, 2004 at 12:49 UTC
    Works for me (after I fixed up your snippet ofcourse). Which version of Wx do you have?
    package crap; use Wx; use base qw(Wx::ProgressDialog); sub new { my $class = shift; my $max = shift || 10; my $vars = (wxPD_CAN_ABORT| wxPD_APP_MODAL|wxPD_ELAPSED_TIME| wx +PD_ESTIMATED_TIME| wxPD_REMAINING_TIME); my $this = $class->SUPER::new("xp6 progres ($max)", "the progres +s ($max)", $max, undef, $vars); $this->Show(1); return $this; } my $c = crap->new(); for(0 .. 10){ $c->Update($_,"the progress ($_/10)",); select undef,undef,undef,0.3; }

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      That's strange that it works for you.

      I just tried yours and I get the same thing. The window is there, but no widgets get drawn until the whole thing is done.

      I'm on Wx-0.20 and wxGTK-2.4.2-3.fr on teh lunix, but it also doesn't work right in windows: Wx-0.19 with wxMSW-2.4.2 (binary). I tried both mine and yours in windows a second ago.

      However, in windows, it doesn't dork around drawing an empty window, it simply sagfaults and kills perl.exe. The 215789 example does work great in windows and gtk.

      So, now I'm guessing that progressdialogs can be made to work without a parent window, but it's flaky and partly luck based?

        Try this version :)
        package crap; use strict; use warnings; use Wx qw[ wxPD_CAN_ABORT wxPD_APP_MODAL wxPD_ELAPSED_TIME wxPD_EST +IMATED_TIME wxPD_REMAINING_TIME ]; use base qw(Wx::ProgressDialog); sub new { my $class = shift; my $max = shift || 10; my $vars = (wxPD_CAN_ABORT| wxPD_APP_MODAL|wxPD_ELAPSED_TIME| wx +PD_ESTIMATED_TIME| wxPD_REMAINING_TIME); my $this = $class->SUPER::new("xp6 progres ($max)", "the progres +s ($max)", $max, undef, $vars); $this->Show(1); return $this; } my $c = crap->new(); for(0 .. 10){ $c->Update($_,"the progress ($_/10)",); select undef,undef,undef,0.3; }
        BTW - for posterity, I have WXMSW-2.5.2, Wx-0.20 .

        It could be a wxGtk bug, you should ask on the wxper-users list.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.