osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Re: Getting screen position - msg#00009

List: gnome.gtk+.perl

Date: Prev Next Index Thread: Prev Next Index
Steve Fox <drfickle@xxxxxxxxx> said:


[...]

> Could you look at my test program and tell me where I'm being stupid
> please?
>
> I greatly appreciate your assistance. Thanks.
>

I didn't tested it but here is the typo I think. be carefull to verify that
when the destroy signal is called, the $window still exists. iirc the destrioy
signal is called just before really destriying it, but not 100% sure.

Anyway you forgot the ->window .

> ---------------------------------------------------------------------
>
> #!/usr/bin/perl -w
>
> use Gtk;
>
> Gtk->init;
>
> my $window = new Gtk::Window;
> $window->signal_connect("destroy", sub { buhbye($window); });
> $window->show_all;
>
> Gtk->main;
>
> exit;
>
> sub buhbye {
> my $window = shift;
>
> print $window->get_name()."\n";
>
> my ($x, $y) = $window->get_position;

my ($x, $y) = $window->window->get_position;

>
> print "x: $x, y: $y\n";
>
> Gtk::main_quit("Gtk");
> }


--
dams


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Getting screen position

On Thu, 2002-12-05 at 12:52, muppet wrote: > the Gtk2 docs say I wish this was Gtk2 :) I like the convenience functions. I should have mentioned I was doing Gtk+-1.2. > so, basically, you want to do > > ($x, $y) = $gtkwindow->window->get_position; I tried that and it told me that I was calling get_position on an undefined value. Could you look at my test program and tell me where I'm being stupid please? I greatly appreciate your assistance. Thanks. --------------------------------------------------------------------- #!/usr/bin/perl -w use Gtk; Gtk->init; my $window = new Gtk::Window; $window->signal_connect("destroy", sub { buhbye($window); }); $window->show_all; Gtk->main; exit; sub buhbye { my $window = shift; print $window->get_name()."\n"; my ($x, $y) = $window->get_position; print "x: $x, y: $y\n"; Gtk::main_quit("Gtk"); } -- Steve Fox http://k-lug.org

Next Message by Date: click to view message preview

Re: Getting screen position

muppet wrote: the Gtk2 docs say [...] oops --- i pasted from the webpage in mozilla, and didn't realize the conversion to plaintext would insert the hyperlinks... here's the cleaned-up version: the Gtk2 docs say void gtk_window_get_position (GtkWindow *window, gint *root_x, gint *root_y); something like ($x, $y) = $gtk2window->get_position; it would appear, however, that for Gtk1.2 (the old gtkperl) you need to dip down to Gdk for this: void gdk_window_get_position (GdkWindow *window, gint *x, gint *y); aye --- Gtk::reference says of Gtk::Gdk::Window $window->get_position () Get the position of the window. This function croaks if not called in list context. so, basically, you want to do ($x, $y) = $gtkwindow->window->get_position; note, also, the important "->window" --- this accesses the GdkWindow owned by the GtkWidget. remember that the GdkWindow doesn't exist until the widget has been realize()d or show()n.

Previous Message by Thread: click to view message preview

Re: Getting screen position

On Thu, 2002-12-05 at 12:52, muppet wrote: > the Gtk2 docs say I wish this was Gtk2 :) I like the convenience functions. I should have mentioned I was doing Gtk+-1.2. > so, basically, you want to do > > ($x, $y) = $gtkwindow->window->get_position; I tried that and it told me that I was calling get_position on an undefined value. Could you look at my test program and tell me where I'm being stupid please? I greatly appreciate your assistance. Thanks. --------------------------------------------------------------------- #!/usr/bin/perl -w use Gtk; Gtk->init; my $window = new Gtk::Window; $window->signal_connect("destroy", sub { buhbye($window); }); $window->show_all; Gtk->main; exit; sub buhbye { my $window = shift; print $window->get_name()."\n"; my ($x, $y) = $window->get_position; print "x: $x, y: $y\n"; Gtk::main_quit("Gtk"); } -- Steve Fox http://k-lug.org

Next Message by Thread: click to view message preview

Re: Getting screen position

On Thu, 2002-12-05 at 16:00, dams@xxxxxx wrote: > my ($x, $y) = $window->window->get_position; I mentioned that above as causing an error. Specifically, Can't call method "get_position" on an undefined value at ./test.pl line 20. Any ideas? Thanks. -- Steve Fox http://k-lug.org
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by