in reply to Starting another Tk GUI MainLoop

MainLoop started in script #1. Also, script #1 has a button, "Start #2".

Transform script #2 into a "standalone" widget, something like:

package Widget2; Construct Tk::Widget 'Widget2'; use Tk; use Tk::Frame; # go ahead and create elements in the widget, like it would be a # standalone app (don't forget to add the close button :D

Somewhere in #1 you have ...

sub load_tool { my $class = shift; my $wdg_plugin; #plugin's own widget eval { require $class . ".pm"; if ( "$class"->isa("Tk::Widget") ) { #If there is a UI then load as widget $wdg_plugin = $mw->$class( #we're sending references )->pack(); } }; #if any errors occurred, report them if ($@) { my $msg = "Initialization of tool $class failed:\n\n"; } }

I hope you got the idea ...

Dodge This!

Replies are listed 'Best First'.
Re^2: Starting another Tk GUI MainLoop
by Ace128 (Hermit) on Jul 18, 2005 at 13:15 UTC
    Ok, this is insteresting. Allthough I wanna avoid doing #2 as a module (or I still can run it as a standalone, eventough its a module?), this is quite nice...
Re^2: Starting another Tk GUI MainLoop
by Ace128 (Hermit) on Jul 18, 2005 at 23:31 UTC
    Ok, just tested this. Application exists when I press the button! So, doesnt really work. Behaves kinda like "require" if I reacall correctly... Seems all works fine until the Mainloop thingy...

    Update: Apparently it DOES work.. Even only with do ("script.pl")!! Fonky. Reason for the exit is that I had exit after the Mainloop statement (dont ask my why). Seems though that somehow the gui pops up nicely without the Mainloop... (But still only one Mainloop is in the works apparently!)
    However, now I got a small "problem" with functions beeing redefined when I press the button again.