2011-07-08 69 views
2

我如何創建一個框架,在所有其他窗口?我也不希望框架被創建爲頂部窗口,我希望用戶有一個可以單擊的按鈕,以便框架進入頂部模式,如果再次單擊它,則會變成正常框架!wxpython框架頂部

我嘗試使用

frame= wx.Frame.__init__(self, None, -1, 'Hello',wx.DefaultPosition,(400,500),style= wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX) 

self.SetTopWindow(self.frame) 

,但我得到一個錯誤,指出self.SetTopWindow不存在。

謝謝

回答

0

我想你想要的是Z順序。谷歌搜索wxPython的窗口ž得到這個:http://wxpython-users.1045709.n5.nabble.com/Bringing-a-Window-to-the-Top-td2289667.html

http://docs.wxwidgets.org/trunk/classwx_window.html#54808c933f22a891c5db646f6209fa4d有這樣一段話:

virtual void wxWindow::Raise (  )  [virtual] 

Raises the window to the top of the window hierarchy (Z-order). 

Notice that this function only requests the window manager to raise this window to the top of Z-order. Depending on its configuration, the window manager may raise the window, not do it at all or indicate that a window requested to be raised in some other way, e.g. by flashing its icon if it is minimized. 

Remarks: 
    This function only works for wxTopLevelWindow-derived classes. 
+0

感謝大家,但我發現了一些http://groups.google.com/ group/wxPython-users/browse_thread/thread/da40922eb7c333cd也有一些例子 – nmnm

10
+0

在使用wx.PopupWindow的wxPython的Windows 7上,我嘗試了這裏討論的兩種方法。 Raise()工作,但也給彈出窗口焦點(不適合我的應用程序),而wx.STAY_ON_TOP沒有關注(這對我的目的是好的)。 –

2

您絕對需要wx.STAY_ON_TOP樣式,但我不知道在創建框架後是否可以實際應用該樣式。請注意,如果在創建init中的框架時使用該樣式,則只會獲得該樣式,並且不會有標題欄或按鈕。所以,你應該常做這樣的:

wx.Frame.__init__(self, None, style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)

2

這是一個老問題,但對於使用記錄:

self.SetWindowStyle(wx.STAY_ON_TOP) 
+0

完美,謝謝。 –