How to make a window always (without exception) stay on top?

Hi,

I have a ToasterBox window
(http://xoomer.alice.it/infinity77/main/ToasterBox.html),
I want it always stay on top even the main frame is iconized or not active.
This window is with flag STAY_ON_TOP already, but it doesn't work when main
frame is not active.

I tried that:

class MyToasterBoxWindow(ToasterBox.ToasterBoxWindow):
    def Show(self, show=True):
        result = ToasterBox.ToasterBoxWindow.Show(self, show)
        self.Raise()
        return result

class MyToasterBox(ToasterBox.ToasterBox):
    """
    Modified ToasterBox to make it always stay on top even the parent window
    is closed or hidden.
    """
    def __init__(self, parent,
                 tbstyle=ToasterBox.TB_SIMPLE,
                 windowstyle=ToasterBox.DEFAULT_TB_STYLE,
                 closingstyle=ToasterBox.TB_ONTIME,
                 scrollType=ToasterBox.TB_SCR_TYPE_DU):
        try:
            # Given None parent to prevent:
            # parent.Bind(wx.EVT_ICONIZE, lambda evt:
            # [w.Hide() for w in winlist])
            # in ToasterBox.py.
            super(MyToasterBox, self).__init__(None,
                tbstyle, windowstyle, closingstyle, scrollType)
        except:
            pass

        self._tb = MyToasterBoxWindow(self._parent, self,
                                      self._tbstyle,
                                      self._windowstyle,
                                      self._closingstyle,
                                      scrollType=scrollType)

        def destroy(event=None):
            if self._tb:
                self._tb.Destroy()
                self._tb = None

            if event:
                event.Skip()

        #parent.Bind(wx.EVT_CLOSE, destroy)
        parent.Bind(wx.EVT_WINDOW_DESTROY, destroy)

But that only make it work when main frame is iconized. If I do not iconize
it, just click on another program to make main frame is inactive, the
ToasterBoxWindow wouldn't show on top even I overwrite the Show method to
Raise it.

How can I make it always show on top without any exception?

Thanks to you very much.

···


View this message in context: http://www.nabble.com/How-to-make-a-window-always-(without-exception)-stay-on-top--tp22120467p22120467.html
Sent from the wxPython-users mailing list archive at Nabble.com.

blp330 wrote:

Hi,

I have a ToasterBox window
(http://xoomer.alice.it/infinity77/main/ToasterBox.html),
I want it always stay on top even the main frame is iconized or not active.
This window is with flag STAY_ON_TOP already, but it doesn't work when main
frame is not active.

But that only make it work when main frame is iconized. If I do not iconize
it, just click on another program to make main frame is inactive, the
ToasterBoxWindow wouldn't show on top even I overwrite the Show method to
Raise it.

How can I make it always show on top without any exception?

First, experiment with the flags a bit. I don't remember details but certain flags will make the window be tied more tightly to the parent frame and will make it hidden when the parent is minimized, etc. so that might be what you are seeing. Also experiment with setting or not setting the parent of the toasterbox.

Second, depending on the platform and environment policies and the configuration settings it may not be possible at all. Things like stay-on-top, raise, etc. are not demands that must be satisfied, but rather requests that you hope the window manager or the system will honor. "Please sir, may I have some more visibility?"

···

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