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 不存在。
谢谢
how can i create a frame that is on top of all the other windows ? also i don't want the frame to be created as an on top window, i want the user to have a button that can be clicked so the frame becomes in on top mode and if it is clicked again then it becomes a normal frame !
i tried using
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)
but i got an error saying that self.SetTopWindow does not exist.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想你可能想看看
self.ToggleWindowStyle(wx.STAY_ON_TOP)
http://docs.wxwidgets 之类的东西。 org/stable/wx_wxwindow.html#wxwindowtogglewindowstyle
和
http://docs.wxwidgets.org/stable/wx_wxframe.html#wxframe
I think you might want to look at something like
self.ToggleWindowStyle(wx.STAY_ON_TOP)
http://docs.wxwidgets.org/stable/wx_wxwindow.html#wxwindowtogglewindowstyle
and
http://docs.wxwidgets.org/stable/wx_wxframe.html#wxframe
这是一个老问题,但仅供记录使用:
It's an old question but for the record use:
您肯定想要 wx.STAY_ON_TOP 样式,但我不知道在创建框架后是否可以实际应用该样式。请注意,如果您在 init 中创建框架时使用该样式,您将只能获得该样式,并且不会有标题栏或按钮。所以你通常应该这样做:
wx.Frame.__init__(self, None, style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
You definitely want the wx.STAY_ON_TOP style, but I don't know if you can actually apply that style after the frame is already created. Note that if you use that style when creating the frame in its init, you will only get that style and you won't have the title bar or buttons. So you should normally do it like this:
wx.Frame.__init__(self, None, style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
我认为你想要的是 Z 顺序。谷歌搜索 wxpython window z 得到这个: http://wxpython-users.1045709.n5.nabble.com/Bringing-a-Window-to-the-Top-td2289667.html
http://docs.wxwidgets.org/trunk/classwx_window.html#54808c933f22a891c5db646f6209fa4d 有这样的说法:
I think what you want is Z-order. Googling wxpython window z got this: http://wxpython-users.1045709.n5.nabble.com/Bringing-a-Window-to-the-Top-td2289667.html
http://docs.wxwidgets.org/trunk/classwx_window.html#54808c933f22a891c5db646f6209fa4d has this to say:
尝试创建不带 wx.STAY_ON_TOP 样式的 UI,然后在类中使用以下内容在样式之间切换 - 确保在初始化 UI 时调用 set_style。
或者如果您使用的是复选框
try creating your UI with no wx.STAY_ON_TOP style, then use the following in your class to switch between styles - make sure to call set_style when initialising your UI.
or if you are using a checkbox