[wxPython] Using wxFRAME_TOOL_WINDOW

As I mentioned on this list yesterday, I would like to use wxPython
to build an MSW 'appbar' (ie, a thingy like the MSW taskbar that
can be positioned to any of the four edges of the screen, and that
does not show up as a button on the taskbar).

I do not want a caption on my appbar (in the interests of conserving
screen space). However, I have not been able to make a main
frame visible when it has both of the attributes wxCAPTION and
wxFRAME_TOOL_WINDOW. Not no how.

The version of the wxPython demo that I have comments out
wxFRAME_TOOL_WINDOW in the code for frames. Fortunately I
found that, by allowing this attribute to be used I was able to get a
frame that does not manifest itself as a button on the taskbar.
Which filled me with cautious delight. It appeared that the
behaviour I want can be obtained when the frame is a child.

Whereupon I whipped up the following code. In it I construct a
dummy parent wxFrame that remains invisible, and a descendant
wxFrame in which wxFRAME_TOOL_WINDOW is on but not
wxCaption. (One class is nested within the other purely for
cosmetic reasons.)

Darn thing seems to work.

You may be waiting with bated breath for my question: Is this
behaviour by design and, in any case, can I expect it to persist for
subsequent versions of wxPython?

Thanks, as always, for your help.

Bill

···

=================

from wxPython . wx import *

class AppBarFrame ( wxFrame ):
  class ActualAppBarFrame ( wxFrame ):
    def __init__ ( self, parent ):
      wxFrame.__init__ ( self, parent, -1, 'Appbar Frame',
        wxDefaultPosition, wxDefaultSize,
        wxFRAME_TOOL_WINDOW |
        wxSTAY_ON_TOP | wxSIMPLE_BORDER )
  
  def __init__ ( self, parent ):
    wxFrame.__init__ ( self, parent, -1, 'Dummy parent for
appbar' )
    self . appbar_frame = self . ActualAppBarFrame ( self )
    self . appbar_frame . Show ( true )
    
class App ( wxApp ):
  def OnInit ( self ):
    frame = AppBarFrame ( None )
    self . SetTopWindow ( frame . appbar_frame )
    return true

if __name__ == '__main__':
  app = App ( 0 )
  app . MainLoop ( )

Which filled me with cautious delight. It appeared that the
behaviour I want can be obtained when the frame is a child.

Whereupon I whipped up the following code. In it I construct a
dummy parent wxFrame that remains invisible, and a descendant
wxFrame in which wxFRAME_TOOL_WINDOW is on but not
wxCaption. (One class is nested within the other purely for
cosmetic reasons.)

This works for me in 2.3.1, no need for the invisible parent:

class AppBarFrame2(wxFrame):
    def __init__(self):
        wxFrame.__init__(self, None, -1, "",
                         style=wxFRAME_TOOL_WINDOW | wxSTAY_ON_TOP |
wxSIMPLE_BORDER)
        self.SetPosition((0,0))
        self.SetSize((1024, 100))

        EVT_LEFT_DOWN(self, self.OnClick)

    def OnClick(self, evt):
        self.Close()

One thing you need to watch out for in your approach is that if the
invisible parent never gets closed then the app will never exit.

···

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