how to get the client rect of the main frame ?

hello,

to print out my main window or any widget on the form,
I've modified Andrea's screenshot creation, to the following code

def Take_ScreenShot ( Widget ) :
  """
  Takes a screenshot of the screen at give pos & size (rect).
  created by Andrea Gavana
  see http://aspn.activestate.com/ASPN/Mail/Message/wxpython-users/3575899
  """

  Rect = Widget.GetRect ()
  Top_Window = Widget.GetTopLevelParent ()

  if Top_Window != Widget :
    Offset_Rect = Top_Window.GetRect ()
    Client_Rect = Top_Window.GetClientRect()
    dX = Offset_Rect.width - Client_Rect.width
    dY = Offset_Rect.height - Client_Rect.height

    Rect.x += Offset_Rect.x + dX - 5
    Rect.y += Offset_Rect.y + dY - 5

This works great for a top window.
But the part for a panel on that top window is ugly, especially the constant -5,
which works on my system, but is probably wrong on other systems.

Is there a better way yo get the absolute screen coordinates of a panel ?

thanks,
Stef Mientki

Hi,

2009/12/12 Stef Mientki:

hello,

to print out my main window or any widget on the form,
I've modified Andrea's screenshot creation, to the following code

def Take_ScreenShot ( Widget ) :
"""
Takes a screenshot of the screen at give pos & size (rect).
created by Andrea Gavana
see ActiveState Community - Boosting coder and team productivity with ready-to-use open source languages and tools.
"""

Rect = Widget.GetRect ()
Top_Window = Widget.GetTopLevelParent ()

if Top_Window != Widget :
Offset_Rect = Top_Window.GetRect ()
Client_Rect = Top_Window.GetClientRect()
dX = Offset_Rect.width - Client_Rect.width
dY = Offset_Rect.height - Client_Rect.height

Rect.x += Offset_Rect.x + dX - 5
Rect.y += Offset_Rect.y + dY - 5

This works great for a top window.
But the part for a panel on that top window is ugly, especially the
constant -5,
which works on my system, but is probably wrong on other systems.

Is there a better way yo get the absolute screen coordinates of a panel ?

Yes, use Widget.GetScreenRect().

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/