#!/usr/bin/perl use strict; use warnings; use Tk; my $mw = MainWindow->new; $mw->Label(-text => 'Main Window')->pack; $mw->Button( -text => 'Quit Main', -command => sub{$mw->destroy}, )->pack; my $top = $mw->Toplevel; $top->Label(-text => 'Top level Window')->pack; $top->Button( -text => 'Exit Top level', -command => sub{$top->destroy}, )->pack; $top->transient($mw); MainLoop;