【问题标题】:wxPython: Exit FullscreenwxPython:退出全屏
【发布时间】:2011-07-04 15:30:00
【问题描述】:

要以全屏模式显示 wxPython 窗口,请使用:

ShowFullScreen(True)

但是,您如何退出全屏模式?我已经尝试了明显的方法:

ShowFullScreen(True)
sleep(5)
ShowFullScreen(False)

但这不起作用。当我运行脚本时,什么都没有出现。 5 秒后,屏幕左上角出现一个大约 200x250 的窗口,其中没有任何内容。它似乎也没有任何边框。

如果我把它改成

showFullScreen(True)

然后我卡住了一个全屏窗口,我必须使用 Alt + F2 -> xkill 才能退出。

【问题讨论】:

    标签: python wxpython


    【解决方案1】:

    看来您需要先Show() 窗口。 (根据documentation,您不应该这样做。也许这是一个错误。)我在 Mac OS X 和 Windows 上进行了测试 - 如果您不先调用 Show(),它们都会出现问题。

    另外请注意,您不应该在主 GUI 线程中休眠。您将挂起 UI。使用CallLater 是一种可能的解决方案,如我的示例所示。

    工作示例:

    import wx
    
    def main():
        app = wx.PySimpleApp()
        frame = wx.Frame(None, -1, 'Full Screen Test')
        frame.Show()
        frame.ShowFullScreen(True)
        wx.CallLater(5000, frame.ShowFullScreen, False)
        app.MainLoop()
    
    if __name__ == '__main__':
        main()
    

    【讨论】:

      【解决方案2】:

      ShowFullScreen 的文档如下:
      ShowFullScreen(show, style=wx.FULLSCREEN_ALL)

      Depending on the value of show parameter the window is either shown full screen or restored to its normal state.
      
      Parameters:
      
          show (bool)
          style (long): is a bit list containing some or all of the following values, which indicate what elements of the window to hide in full-screen mode:
              wx.FULLSCREEN_NOMENUBAR
              wx.FULLSCREEN_NOTOOLBAR
              wx.FULLSCREEN_NOSTATUSBAR
              wx.FULLSCREEN_NOBORDER
              wx.FULLSCREEN_NOCAPTION
              wx.FULLSCREEN_ALL (all of the above)
      

      因此,将您的全屏切换事件放在菜单中并使用以下命令启动全屏模式:
      self.window.ShowFullScreen(True, style=(wx.FULLSCREEN_NOTOOLBAR | wx.FULLSCREEN_NOSTATUSBAR |wx.FULLSCREEN_NOBORDER |wx.FULLSCREEN_NOCAPTION))

      请注意,我省略了 wx.FULLSCREEN_NOMENUBAR,这样您仍然可以访问菜单以再次关闭全屏模式。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-09-28
        • 2017-04-19
        • 2023-03-19
        • 2010-11-20
        • 1970-01-01
        • 2013-10-21
        相关资源
        最近更新 更多