[wxPython-users] drawing a popup

Robin Dunn robin at alldunn.com
Mon Feb 4 10:46:54 PST 2008


Greg H wrote:
> I'm having some trouble drawing a popup box over a panel that has many 
> different widgets in it. Right now I'm just using BufferedDC and 
> DrawRectangle to draw the popup box at the position of the mouse 
> whenever it is clicked. However, instead of it being drawn over all of 
> the widgets in the panel it's drawn under them. Is there a way that I 
> can draw it so that it will be displayed over the widgets instead of 
> under them? 

Yes and No.  Painting on parents automatically clips the areas occupied 
by children, but using a wx.WindowDC will probably let you do what you 
want as long as it is a transient kind of thing.  Otherwise as soon as 
the child widgets redraw themselves they will overwrite what you do with 
the wx.WindowDC.  OTOH, the use of wx.WindowDC is starting to be 
discouraged because it doesn't always play well with modern compositing 
(a.k.a. double buffered) UI systems.


> Or is there something else I can use to implement a popup 
> box (other than drawing it myself using a DC)?

Use another window.  There is the wx.PopupWindow class although it is 
not fully implemented yet for wxMac.  Another possibility is to use a 
borderless frame or dialog.

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





More information about the wxpython-users mailing list