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


In reply to Embedding another app in a Perl::Tk frame (in Unix) by {NULE}
in thread Tk and processes as child/sub windows by bbfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.