warpod has asked for the wisdom of the Perl Monks concerning the following question:
when I click the button I need a new window x/y absolute coordinates to be positioned right at the x/y absolute coordinates of the button, so the new window will overlap the button every time I click it.#!/usr/bin/perl -w use strict; use Tk; my $w = MainWindow->new; my $button; $button = $w->Button(-text => "click me", -command => sub { my $mw = $w->Toplevel; # here I need somehow position the $mw over the $button $mw->Label(-text => "hello")->pack(); })->pack; MainLoop;
my @wg = ($w->geometry =~ /\+(\d+)\+(\d+)/); my @bg = ($button->geometry =~ /\+(\d+)\+(\d+)/); $wg[$_] += $bg[$_] for (0..@wg-1); $mw->geometry("+$wg[0]+$wg[1]");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tk widget coordinates, simple question
by AnomalousMonk (Archbishop) on Jan 05, 2010 at 17:48 UTC | |
by warpod (Novice) on Jan 05, 2010 at 18:01 UTC | |
|
Re: Perl/Tk widget coordinates, simple question
by zentara (Cardinal) on Jan 06, 2010 at 12:00 UTC |