#!/usr/bin/perl -w use strict; use Tk; require Tk::TopLevel; sub newWindow(); sub closeWindow(); my $TestWindow; my $main = MainWindow->new(); $main->Button( -text => "Click Me", -command => \&newWindow)->pack(); MainLoop; sub newWindow () { $TestWindow = $main->TopLevel(); $TestWindow->Label ( -text => "I want to make a new toplevel window!")->pack(); $TestWindow->Button( -text => "Close Me", -command => \&closeWindow)->pack(); } sub closeWindow() { $TestWindow->destroy(); }