Newbie: How to program window -> serial code -> window?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Newbie: How to program window -> serial code -> window?

Tokuyasu, Taku

Hello,

 

I’m trying to do the following:

  1. Open up a window (Entry) to get filenames
  2. Close the window, and make a system call to an executable with the above filename arguments
  3. Open up a different window when the system call finishes (e.g. a dialog box with different options)

I’m not sure if this is obvious or not.  I tried simply duplicating a code block starting with “use Gtk2 '-init':” and ending with “Gtk2->main;”, with the system call in between, but the first window did not disappear after quit’ing the window, instead hanging around until the second window quit.

 

Perhaps I shouldn’t quit the windows, just have them both hanging around and show/hide them as needed?  I’m wondering what the paradigm here should be.

 

Any suggestions greatly appreciated.

 

_Taku

 

 


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

RE: Newbie: How to program window -> serial code -> window?

Tokuyasu, Taku

 

Sorry – forgot to mention, I’m using ActiveState Perl, Gtk2 from http://gtk2-perl.sourceforge.net/win32/ppm/, on a WindowsXP machine.

 

_Taku

 

 


From: Tokuyasu, Taku
Sent: Tuesday, July 05, 2005 10:34 PM
To: '[hidden email]'
Subject: Newbie: How to program window -> serial code -> window?

 

Hello,

 

I’m trying to do the following:

  1. Open up a window (Entry) to get filenames
  2. Close the window, and make a system call to an executable with the above filename arguments
  3. Open up a different window when the system call finishes (e.g. a dialog box with different options)

I’m not sure if this is obvious or not.  I tried simply duplicating a code block starting with “use Gtk2 '-init':” and ending with “Gtk2->main;”, with the system call in between, but the first window did not disappear after quit’ing the window, instead hanging around until the second window quit.

 

Perhaps I shouldn’t quit the windows, just have them both hanging around and show/hide them as needed?  I’m wondering what the paradigm here should be.

 

Any suggestions greatly appreciated.

 

_Taku

 

 


_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|

Re: Newbie: How to program window -> serial code -> window?

muppet-6
In reply to this post by Tokuyasu, Taku

On Jul 6, 2005, at 1:31 AM, Tokuyasu, Taku wrote:

> I’m trying to do the following:
>
> Open up a window (Entry) to get filenames
> Close the window, and make a system call to an executable with the  
> above filename arguments
> Open up a different window when the system call finishes (e.g. a  
> dialog box with different options)
> I’m not sure if this is obvious or not.  I tried simply duplicating  
> a code block starting with “use Gtk2 '-init':” and ending with  
> “Gtk2->main;”, with the system call in between, but the first  
> window did not disappear after quit’ing the window, instead hanging  
> around until the second window quit.
The second "use Gtk2 -init" is unnecessary; the initialization only  
does anything the first time.

You don't "quit a window" -- you quit an event loop (referred to as a  
"main loop").  In many of the small examples shown here on the list,  
we set up the window to kill the main loop on the window's  
destruction, like this:

    $window->signal_connect (destroy => sub {Gtk2->main_quit});

That says, "when the window is destroyed, stop the main loop".  The  
destruction of the window is triggered elsewhere, such as by the  
default handler for the window's delete-event.

You must either ->hide or ->destroy a window to remove it from the  
screen.  The first window stays visible because you never told it not  
to be.

A reasonable template would be:


    use Gtk2 -init;
    # assume create_first_dialog is a function that creates a
    # Gtk2::Dialog with the desired action buttons.
    $dialog = create_first_dialog ();
    $response = $dialog->run;
    $dialog->destroy;  # remove the dialog from the screen
    exit 0 if $response ne 'ok';

    @input = `$command`;  # program blocks here while reading input

    $dialog = create_second_dialog (@input);
    $dialog->run;
    $dialog->destroy;


Of course, if you want the ui to remain responsive during the call-
out so that you can display progress or something like that, you need  
to take other measures.  Look in the FAQ under "how do i keep my UI  
responsive during long file reads?"


--
If I lived in Teletubby Land, the homicide rate would be four.
   -- elysse

_______________________________________________
gtk-perl-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-perl-list