#!perl package Editform; use strict; use warnings; use Tk; sub new { my $class = shift; my $parent = shift; my $self = bless({}, $class); $self->{'__PARENT'} = $parent; return $self; } # /new sub display { my $self = shift; my $parent = $self->{'__PARENT'}; my $tl = $parent->Toplevel(-width => 200, -height => 200, -bg => 'blue',); return; } # /display 1; package Userimages; use strict; use warnings; use Tk; sub new { my $class = shift; my $parent = shift; my $self = bless({}, $class); $self->{'__PARENT'} = $parent; return $self; } # /new sub display { my $self = shift; my $parent = $self->{'__PARENT'}; my $tl = $parent->Toplevel(-width => 200, -height => 200, -bg => 'yellow',); return; } # /display 1; package main; use strict; use warnings; use Tk; my $mw = tkinit(); $mw->Button( -text => 'dialog1', -command => sub{ my $form = Editform->new($mw); $form->display(); }, )->pack(); $mw->Button( -text => 'Userimages', -command => sub{ my $form = Userimages->new($mw); $form->display(); }, )->pack(); $mw->MainLoop();