2011-07-08 68 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

完美,谢谢。 –