Hi,
As we kind of figured out before Tk::Toplevel and Tk::Frame both accept -container => 1 as an option. The trick is getting another application to accept that window as it's parent.
You can get the window manager's id for this window very simply. If we had created a frame that we want to work as a container we could say the following:
my $frame = $main->Frame(
-container => 1, -width => 320, -height => 240
)->pack(
-side => 'top',
-fill => 'both',
-expand => 1
);
We can get the window manager's ID with the id method:
my $frameID = $frame->id;
print "My ID is: $frameID\n";
If you check the docs for Tk::Widget you see that the id method returns "a hexadecimal string giving a low-level platform-specific identifier"... on UNIX it returns "the X window identifier", on Win "the Windows HWND". The key now is to get another app to accept this ID as its parent.
This seems like it would be something available in a uniform fashion to any application built on the X Toolkit. I could not find any way to specify a parent using the "standard options" of the toolkit. I also tried using the X Resource Management features of the toolkit to see if such an option was available there. I had no luck persuing these.
Another thing I did was to delve a bit into some sample X Toolkit code. There seems to be a point in the application where you can specify a parent ID. If my reading is correct the question is - does the toolkit offer a standard way to specify this? (I would think so because it seems the window manager would be the parent of any newly created application.) If not, how would you build an application to accept this value and use the parent provided.
There is an example (albeit in Tcl/Tk) on the web: http://www.xmission.com/~georgeps/multimedia.html that uses xanim. xanim explicitly accepts a parent id using the +W command line argument. Doing the same kind of thing in Perl::Tk looks like this:
#! /usr/local/bin/perl -w
use strict;
use Tk;
my $main = MainWindow->new(
-title => 'Container Test'
);
my $frame1 = $main->Frame->pack(
-side => 'top',
-fill => 'x'
);
my $frame2 = $main->Frame(
-container => 1, -width => 320, -height => 240
)->pack(
-side => 'top',
-fill => 'both',
-expand => 1
);
my $frame3 = $main->Frame->pack(
-side => 'top',
-fill => 'x'
);
$frame1->Button(-text => 'xanim', -command => [ \&open_xterm, $frame2
+])->pack;
$frame1->Button(-text => 'Quit', -command => \&exit)->pack;
$frame1->Label(-text => "This is above the container frame")->pack;
$frame3->Label(-text => "This is below the container frame")->pack;
MainLoop;
exit;
sub open_xterm
{
my $frame = shift;
my $display = "xanim -Zr +W".$frame->id." /space/litherm/TheDamian
+.gif &";
print $display,"\n";
system($display);
}
Thanks to TheDamian for use of his gif in testing. :)
I hope this helps you. Good luck,
{NULE}
--
http://www.nule.org |