Think about Loose Coupling | |
PerlMonks |
Re: Opening another Perl script in Current Window using the perl Tk moduleby kcott (Archbishop) |
on Sep 14, 2016 at 12:31 UTC ( [id://1171736]=note: print w/replies, xml ) | Need Help?? |
G'day TheNewGuyShubh, Welcome to the Monastery. "I am trying to open ... another Tk perl Gui window ... in my current perl tk Window." Below, I've referred to the current window as the master and the window (opened in the master) as the slave. This operation is called embedding. You create the master with either a Tk::Frame, a Tk::Toplevel or a Tk::MainWindow, which has its '-container' option set to a TRUE value. This container widget is where the slave will be embedded: you'll need its ID ($container->id) which is explained in Tk::Widget. You create the slave with a Tk::MainWindow which has its '-use' option set to the container ID. Important: All of the code below is intended to demonstrate a technique only! It is very much bare-bones code. To make it production-ready, you'll need to add validation, error-checking and so on. First, let's look at an example slave (pm_1171590_tk_embed_slave.pl). Note that this can be run both as a stand-alone and an embedded application.
Running this as stand-alone without arguments produces a GUI like this:
Attempting to run stand-alone with arguments, generates an error like this:
Now let's look at an example master (pm_1171590_tk_embed_master.pl) that may (or may not) have a specified slave.
Running without a specified slave.
produces a GUI which looks like
Running with a specified slave.
produces a GUI which looks like
— Ken
In Section
Seekers of Perl Wisdom
|
|