[wxPython-users] Re: wx.MDIChildFrame = tabbed window (Linux)? / design problems

Robin Dunn robin at alldunn.com
Thu Apr 5 17:52:41 PDT 2007


Bjoern Schliessmann wrote:

> Strange, it _is_ the only child ... (Or am I getting something
> wrong?)
> 
> mainWindowSize = (1024,768)
> 
> mainWindowStyle = (wx.DEFAULT_FRAME_STYLE
>                     ^wx.MAXIMIZE_BOX
>                     ^wx.MINIMIZE_BOX
>                     ^wx.CLOSE_BOX
>                     ^wx.RESIZE_BORDER)
> # ...
> class MainFrame(wx.Frame):
>     def __init__(self, parent, id, pos):
>         wx.Frame.__init__(self,
>                           parent,
>                           id,
>                           "Main Menu",
>                           size = mainWindowSize,
>                           style = mainWindowStyle,
>                           pos=pos)
> 
>         self.panel = panel = wx.Panel(self, -1)
>         print self.GetSize(), panel.GetSize() 

At this point in time the frame has not yet recieved a EVT_SIZE event, 
and that is where it does the autolayout work.


>         panel.SetBackgroundColour("Black")
>         self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
>         self.createMenuBar()
> 
>     # ...     
> 
> The above "print" gives (1024,768) (20,20), but the frame background
> is all black.

By the time it is visible then the size event has happened and the panel 
has been resized to fill the frame.


> 
> If I add a sizer
> 
>         # ...
>         panel.SetBackgroundColour("Black")
>         panelSizer = wx.BoxSizer()
>         panelSizer.Add(self.panel)
>         self.SetSizer(panelSizer)
>         panelSizer.Layout()
>         # ...
> 
> the black frame background shrinks to a ... (20,20) square. An
> identical print statement like above gives the same (namely,
> 1024x768) (20,20)).

Same here, except you didn't tell the sizer to expand the panel so it 
will leave it at it's default size.


> 
> Also, how can I get window-local coordinates? I'd like to get the
> (0,0) in self.panel's coordinates as screen coordinates.
> 
> If I insert, in the above __init__, the following
> 
> print self.ClientToScreenXY(0,0)
> 
> it yields (0,0). But my window is not positioned in a way that the
> panel's (0,0) is in the upper left hand corner of the screen :( Is
> my approach wrong?

Same problem again.  In the __init__ the frame hasn't been shown or 
mapped to the screen yet, so it doesn't have screen coordinates to work 
from.


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





More information about the wxpython-users mailing list