使用wxpython写的界面程序其实也是可以设置Z-order的。
可以使用pywin32模块调用win32的API实现,使用方法不在赘述。
如果仅仅是想将窗口置顶(放在其他窗口上面,Z-order顶部),有一个简单的方法:
在wx.Frame中调用一下这个方法
self.ToggleWindowStyle(wx.STAY_ON_TOP)
或者
self.SetWindowStyle(wx.STAY_ON_TOP)
注意,wx.Raise()的方法是有限制的,如下的Remark
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.
如果始终置顶,可以在wx.Frame init里面加入属性,如
def __init__(self,parent=None,id=-1,
pos=wx.DefaultPosition,
title='Hello',
style=wx.DEFAULT_FRAME_STYLE^(wx.MINIMIZE_BOX|wx.MAXIMIZE_BOX) | wx.STAY_ON_TOP):
enjoy ^_^