#!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new(); my $canv = $mw->Canvas(-bg => 'lightsteelblue', -relief => 'sunken', -width => 500, -height => 400)->pack(-expand => 1, -fill => 'both'); my $xtermWidth = 400; my $xtermHeight = 300; ## this Frame is needed for including the xterm in Tk::Zinc my $xtermContainer = $canv->Frame(-container => 1); my $xtid = $xtermContainer->id(); print "$xtid\n"; # converting the id from HEX to decimal as xterm requires a decimal Id my ($xtId) = sprintf hex $xtid; print "$xtId\n"; my $label = $canv->createText( 250,10, -text => "Hide xterm", ); my $dcontitem = $canv->createWindow(250,175, -window => $xtermContainer, -width => $xtermWidth+4, -height => $xtermHeight+4, -state => 'normal'); $canv->bind($label, '<1>', \&hideShow); sub hideShow { if ($canv->itemcget($label, -text) =~ /Hide/) { $canv->itemconfigure($label, -fill => 'yellow', -text => "Show xterm"); $canv->itemconfigure($dcontitem, -state => 'hidden'); } else { $canv->itemconfigure($label, -fill => 'black', -text => "Hide xterm"); $canv->itemconfigure($dcontitem, -state => 'normal'); } } my $width = $xtermWidth/10; my $height = $xtermHeight/20; $mw->Button(-text => "Toplevel", -command => \&do_Toplevel)->pack( ); system("xterm -fn 10x20 -geometry ${width}x${height} -into $xtId &"); MainLoop(); sub do_Toplevel { my $tl = $mw->Toplevel(-use=>$xtId ); $tl->title("Toplevel"); $tl->Button(-text => "Close", -command => sub { $tl->withdraw })->pack; } __END__