wxpython 面板全屏? [英] wxpython panel fullscreen?

查看:31
本文介绍了wxpython 面板全屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的程序的 top_panel 只进入全屏,我希望有一个按钮可以做到这一点,我面临的问题是我不知道如何让面板自己进入全屏而不使用 ShowFullscreen(true) 强制整个帧进入全屏

I am trying to make my top_panel of my program go into fullscreen only, i hope to have a button which will do this, the issue i am faced with is i dont know how to make the panel go into fullscreen it self without forcing the whole frame to go into fullscreen using ShowFullscreen(true)

希望你能帮到我

class top_panel(wx.Panel):

def __init__(self, parent):
    wx.Panel.__init__(self, parent=parent, size=(400,175))
    self.SetBackgroundColour('BLACK')
    self.ofullscreen = wx.Button(self, -1, "Fullscreen", (10,30))
    self.ofullscreen.Bind(wx.EVT_BUTTON, self.onfullscreen, self.ofullscreen)
    self.gbs = wx.GridBagSizer(2,2)
    self.Bind(wx.EVT_KEY_DOWN, self.onKey)
    wx.Frame.ShowFullScreen(True)
#----------------------------------------------------------------------
def onKey(self, event):
    """
    Check for ESC key press and exit is ESC is pressed
    """
    key_code = event.GetKeyCode()
    if key_code == wx.WXK_ESCAPE:
        self.GetParent().Close()
    else:
        event.Skip()   

def onfullscreen(self):
    print "hola"
    #self.fullscreen?????

推荐答案

我在我的博客上写过关于这个主题的文章.举个例子:

I have written about this subject on my blog. Here's an example:

import wx


class MyPanel(wx.Panel):
    """"""

    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        self.Bind(wx.EVT_KEY_DOWN, self.onKey)

    def onKey(self, event):
        """
        Check for ESC key press and exit is ESC is pressed
        """
        key_code = event.GetKeyCode()
        if key_code == wx.WXK_ESCAPE:
            self.GetParent().Close()
        else:
            event.Skip()


class MyFrame(wx.Frame):
    """"""

    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Test FullScreen")
        panel = MyPanel(self)
        self.ShowFullScreen(True)


if __name__ == "__main__":
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()

我注意到此代码似乎不适用于 Mac.

I have noticed that this code doesn't seem to work with Macs.

这篇关于wxpython 面板全屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆