position frame relative to a matplotlib plot point

I am getting myself pretty confused about this and asked on the
matplotlib list and so far haven't gotten it figured out. Since I
realize now this is more a wxPython issue, I ask here.
(Concern seen on both WinXP and Ubuntu; using wxPython 2.8.10, Python 2.5).

I want to place a shaped wxFrame at a location on the screen based on
the location of a picked point in a matplotlib plot that is embedded
in a wxPython GUI. The hierarchy of objects is:

wxFrame
    - wxPanel (background panel)
        - AUINotebook
            - wxPanel (page in the notebook)
                - matplotlib canvas (and figure)

I've tried a number of different ways and the position at which the
shaped frame appears is always displaced from the picked point on the
plot.

I have been trying to make use of something like:

mouseLocation = wx.GetMousePosition()
shapedFrame.Move(mouseLocation)

But that gives me a large vertical displacement. If I use

mouseLocatioin = wx.GetMousePosition()
pos = self.ClientToScreen(mouseLocation)
shapedFrame.Move(pos)

That is no better. Based on Chris's suggestion on the matplotlib
list, I have been printing out coordinates, but so far I haven't been
able to figure out how to use them to help me understand what to do.

Any ideas would be appreciated.

Thanks,
Che

I would have expected either of those to work. How large is a "large vertical displacement"? Is it is okay horizontally? What does it look like if you use a normal (unshaped) frame?

···

On 1/24/10 9:25 AM, C M wrote:

I've tried a number of different ways and the position at which the
shaped frame appears is always displaced from the picked point on the
plot.

I have been trying to make use of something like:

mouseLocation = wx.GetMousePosition()
shapedFrame.Move(mouseLocation)

But that gives me a large vertical displacement. If I use

mouseLocatioin = wx.GetMousePosition()
pos = self.ClientToScreen(mouseLocation)
shapedFrame.Move(pos)

That is no better. Based on Chris's suggestion on the matplotlib
list, I have been printing out coordinates, but so far I haven't been
able to figure out how to use them to help me understand what to do.

--
Robin Dunn
Software Craftsman

As it turns out, they do work, but there is a discrepancy between how
Windows positions the shaped frame and how Linux does, and that
discrepancy has been fouling my efforts. I can have the shaped frame
pointing to the exact right spot on one platform, but it is displaced
vertically in the other. I think this is because one is basing the
positioning on the size of the original frame before it is shaped, and
the other is somehow taking into account the shaped frame's size...or
something like that. I'm zeroing in on a solution and will report on
that when I get to it.

Thanks,
Che

···

On Mon, Jan 25, 2010 at 1:40 PM, Robin Dunn <robin@alldunn.com> wrote:

On 1/24/10 9:25 AM, C M wrote:

I've tried a number of different ways and the position at which the
shaped frame appears is always displaced from the picked point on the
plot.

I have been trying to make use of something like:

mouseLocation = wx.GetMousePosition()
shapedFrame.Move(mouseLocation)

But that gives me a large vertical displacement. If I use

mouseLocatioin = wx.GetMousePosition()
pos = self.ClientToScreen(mouseLocation)
shapedFrame.Move(pos)

That is no better. Based on Chris's suggestion on the matplotlib
list, I have been printing out coordinates, but so far I haven't been
able to figure out how to use them to help me understand what to do.

I would have expected either of those to work. How large is a "large
vertical displacement"? Is it is okay horizontally? What does it look like
if you use a normal (unshaped) frame?

After spending more time on this than I expected, and realizing that
it was really just off by a fixed amount depending on platform, in the
end I decided to just give up on doing it the "right" way and just
check the platform and add the platform-appropriate value.

Che

···

On Tue, Jan 26, 2010 at 2:48 PM, C M <cmpython@gmail.com> wrote:

On Mon, Jan 25, 2010 at 1:40 PM, Robin Dunn <robin@alldunn.com> wrote:

On 1/24/10 9:25 AM, C M wrote:

I've tried a number of different ways and the position at which the
shaped frame appears is always displaced from the picked point on the
plot.

I have been trying to make use of something like:

mouseLocation = wx.GetMousePosition()
shapedFrame.Move(mouseLocation)

But that gives me a large vertical displacement. If I use

mouseLocatioin = wx.GetMousePosition()
pos = self.ClientToScreen(mouseLocation)
shapedFrame.Move(pos)

That is no better. Based on Chris's suggestion on the matplotlib
list, I have been printing out coordinates, but so far I haven't been
able to figure out how to use them to help me understand what to do.

I would have expected either of those to work. How large is a "large
vertical displacement"? Is it is okay horizontally? What does it look like
if you use a normal (unshaped) frame?

As it turns out, they do work, but there is a discrepancy between how
Windows positions the shaped frame and how Linux does, and that
discrepancy has been fouling my efforts. I can have the shaped frame
pointing to the exact right spot on one platform, but it is displaced
vertically in the other. I think this is because one is basing the
positioning on the size of the original frame before it is shaped, and
the other is somehow taking into account the shaped frame's size...or
something like that. I'm zeroing in on a solution and will report on
that when I get to it.

Thanks,
Che

What are the values you ended up using? Do they happen to be approximately the same size as the title bar, or perhaps the amount of space between the visible portion of your shaped frame and where its top point would be without the shaping?

···

On 1/26/10 12:47 PM, C M wrote:

After spending more time on this than I expected, and realizing that
it was really just off by a fixed amount depending on platform, in the
end I decided to just give up on doing it the "right" way and just
check the platform and add the platform-appropriate value.

--
Robin Dunn
Software Craftsman

After spending more time on this than I expected, and realizing that
it was really just off by a fixed amount depending on platform, in the
end I decided to just give up on doing it the "right" way and just
check the platform and add the platform-appropriate value.

What are the values you ended up using? Do they happen to be approximately
the same size as the title bar, or perhaps the amount of space between the
visible portion of your shaped frame and where its top point would be
without the shaping?

I had to move things about 15 pixels down on Linux, and yes, I believe
this corresponds to the latter difference you mentioned--actually, a
variation on that. My shaped frame is a kind of balloon popup with a
pointing part, and I need things to be positioned relative to the tip
of the point, and that tip in the image did not reach all the way down
to the SW corner of the frame, so it was that difference that
mattered. Since positioning works on the NW corner of a frame, I was
subtracting the height of the whole frame to move it up, but I needed
to subtract only height_of_whole_frame - 15px.

I wonder if Windows calculates the height of the frame *when shaped*
whereas Linux calculates it *without shaping*--this would make sense
in terms of the problem I'd had. (Another solution is to remake my
image so the image's height exactly equals the frame's height).

Thanks for your help,
Che

···

On Fri, Jan 29, 2010 at 10:14 PM, Robin Dunn <robin@alldunn.com> wrote:

On 1/26/10 12:47 PM, C M wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

I wonder if Windows calculates the height of the frame *when shaped*
whereas Linux calculates it *without shaping*--this would make sense
in terms of the problem I'd had.

Yes, that is what I was thinking as well, and was why I asked the questions. If so then I would say that your workaround is the proper thing to do.

(Another solution is to remake my
image so the image's height exactly equals the frame's height).

Although this would certainly make things simpler.

···

On 2/1/10 10:23 AM, C M wrote:

--
Robin Dunn
Software Craftsman