[wxPython] Fw: Dereferencing Pointers

Or to put it another way. What is the syntax you use with a pointer to get at what it is pointing to?

-Mikhael

···

----- Original Message -----
From: Mikhael Loo

To: wxpython-users@lists.wxwindows.org

Sent: Thursday, May 24, 2001 6:45 PM

Subject: Dereferencing Pointers

I’m using wxMDIParentFrame::GetActiveChild to try and get at the customized children of an MDI app I’m working on. I want to access one of the Currently active child’s objects but I don’t know how to manipulate the wxMDIChildFramePtr that I get back.

How do I go from wxMDIChildFramePtr to the Child it is pointing at?

-Mikhael

[Please don't send html mail to this list...]

I'm using wxMDIParentFrame::GetActiveChild to try and get at
the customized children of an MDI app I'm working on. I want
to access one of the Currently active child's objects but I
don't know how to manipulate the wxMDIChildFramePtr that I get
back.

How do I go from wxMDIChildFramePtr to the Child it is pointing
at?

Or to put it another way. What is the syntax you use with a
pointer to get at what it is pointing to?

There is currently no built-in way to go from an arbitrary object returned
from a C++ method (and wrapped in a Python object) back to the original
Python object. This is something I hope to remedy for the next release, but
currently you'll have to do some work to get it.

If you look at the .this attribute of the python object you'll see a string
with a hex number and a class type in it. The hex number is the C++ pointer
to the C++ object, so you could use that as a way of identifying the orginal
object, just compare that value to the .this in your collection of child
windows.

Or you could use .GetId() the same way. Just keep a dictionary of child
windows where the key is the ID value, then you can get your original object
by doing something like this:

    child = self.childMap[self.GetActiveChild().GetId()]

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Thanks. the GetId() Idea worked great for me...

   -Mikhael

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Friday, May 25, 2001 3:49 PM
Subject: Re: [wxPython] Fw: Dereferencing Pointers

[Please don't send html mail to this list...]

> I'm using wxMDIParentFrame::GetActiveChild to try and get at
> the customized children of an MDI app I'm working on. I want
> to access one of the Currently active child's objects but I
> don't know how to manipulate the wxMDIChildFramePtr that I get
> back.
>
> How do I go from wxMDIChildFramePtr to the Child it is pointing
> at?
>
> Or to put it another way. What is the syntax you use with a
> pointer to get at what it is pointing to?

There is currently no built-in way to go from an arbitrary object returned
from a C++ method (and wrapped in a Python object) back to the original
Python object. This is something I hope to remedy for the next release,

but

currently you'll have to do some work to get it.

If you look at the .this attribute of the python object you'll see a

string

with a hex number and a class type in it. The hex number is the C++

pointer

to the C++ object, so you could use that as a way of identifying the

orginal

object, just compare that value to the .this in your collection of child
windows.

Or you could use .GetId() the same way. Just keep a dictionary of child
windows where the key is the ID value, then you can get your original

object

by doing something like this:

    child = self.childMap[self.GetActiveChild().GetId()]

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users