How to make a Frame always on top?

Robin Dunn:

  I tried SetWindowStyle to change the style and it works on WinXP,python23,wxpython2.5.2.8. here is the sample code:

"""
author: Bruce Who
date: 2005-03-10
$Revision$
description: 这个演示了
    - 如何动态的改变Frame的style
    - 如何使用Frame总在最上
"""
import wx

class myFrame(wx.Frame): # {{{
    def __init__(self, parent):
        wx.Frame.__init__(self, parent,-1,style=wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)
        self.Bind(wx.EVT_LEFT_UP,self.OnClick) #,self.panel_)
        self.flag_ = True
    def OnClick(self,evt):
        ## 改变窗口的样式
        if self.flag_:
            self.SetWindowStyle(wx.DEFAULT_FRAME_STYLE)
        else:
            self.SetWindowStyle(wx.DEFAULT_FRAME_STYLE|wx.STAY_ON_TOP)
        self.flag_ = not self.flag_
        print 'click'
# }}}

def main(): # {{{
    app = wx.PySimpleApp(0)
    frame = myFrame(None)
    frame.Show(True)
    app.SetTopWindow(frame)
    app.MainLoop()
# }}}

if __name__ == "__main__":main()

======= 2005-03-11 09:53:10 Robin Dunn wrote: =======

Bruce Who wrote:

Peter Damoc:

   thanks, it works fine. And I wonder is it possible to toggle it?
For example:

     ## make the frame always on top
     frame.SetAlwaysOnTop(True)
     ...
     ## disable it
     frame.SetAlwaysOnTop(False)

No you would have to recreate the window to change that style.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

.

= = = = = = = = = = = = = = = = = = = =
      
Bruce Who
HuXuZhao@hotmail.com
2005-03-11