#!/usr/bin/perl -w use strict; use Tk; use Tk::Pane; use Tk::HList; sub door { my $house = shift; my $door_W = $house->Toplevel(); my $hlist = $door_W->Scrolled( 'HList', -scrollbars => "se", -columns => 1, -header => 1, )->pack( -expand => 1, -fill => 'both'); $hlist->headerCreate(0, -text => 'Title'); $hlist->columnWidth(0, ''); $hlist->bind("" => [\&knock_on_door, $door_W]); my $exit_B = $door_W->Button( -text => 'Exit', -command => sub { $door_W->destroy(); }, -relief => 'raised', )->pack(-side => 'left'); } sub knock_on_door { my $frame = shift; my $pop_menu = $frame->Menu( -menuitems => [ ['command', 'Knock on door.', -command => sub { print "Knock! Knock!!!\n"; } ], '', ] )->Popup(-popover => "cursor", -popanchor => 'nw'); $pop_menu->destroy; } my $mw = MainWindow->new; $mw->Button(-text => "Close", -command =>sub{exit})->pack(); door($mw); MainLoop;