第二个面板内的Wigets消失

时间:2018-02-22 02:44:41

标签: python python-3.x user-interface wxwidgets

这是"第二部分"到this question.
所以我有这个(相同的)代码:

import wx
import screeninfo

class application(wx.Frame):
    def __init__(self, *args, **kw):
        super(application, self).__init__(*args, **kw)
        # Panels
        panel = wx.Panel(self)
        StuffPanel = wx.Panel(panel, 1)
        # Header
        Header = wx.StaticText(panel, label="Browse", pos=(25, 25))
        HeaderFont = Header.GetFont()
        HeaderFont.PointSize += 10
        HeaderFont = HeaderFont.Bold()
        Header.SetFont(HeaderFont)
        # displaying everything in 'override_contents.py'
        import override_contents as over
        posx = 25
        posy = 60
        change = 0
        def contentButtonDisplay(panel=StuffPanel, id=wx.ID_ANY, label="None", pos=(0,0), event=None, i=None):
            wx.Button(panel, id, label, pos).Bind(wx.EVT_BUTTON, event)
        for i in over.contents:
            contentButtonDisplay(label=i["name"], pos=(posx, posy), event=i["event"])
            if change == 5:
                posy += 50
                posx = 25
                change = 0
            else:
                posx += 100
                change += 1

for m in screeninfo.get_monitors():
    r1 = str(m).split("x")
    screenx = r1[0].split("(")[1]
    screeny = r1[1].split("+")[0]

app = wx.App()
frm = application(None, title='Browse', size=(int(screenx), int(screeny)))
frm.Show()
app.MainLoop()

并覆盖_内容:

import wx
def onPygame():
    wx.MessageBox("Pygame!", "Pygame!")
def onWxpython():
    wx.MessageBox("WxPython!", "WxPython")
def onScreeninfo():
    wx.MessageBox("Screeninfo", "Screeninfo")
contents=[
    {
        "name" : "PyGame",
        "event": lambda _: onPygame()
    },
    {
        "name": "WxPython",
        "event" : lambda _: onWxpython()
    },
    {
        "name": "Screeninfo",
        "event" : lambda _: onScreeninfo()
    },
{
        "name": "Screeninfo",
        "event" : lambda _: onScreeninfo()
    },
{
        "name": "Screeninfo",
        "event" : lambda _: onScreeninfo()
    },
{
        "name": "Screeninfo",
        "event" : lambda _: onScreeninfo()
    },
{
        "name": "Screeninfo",
        "event" : lambda _: onScreeninfo()
    }
]

所以我试图使用两个面板,panelStuffPanel panel是主面板,StuffPanel是放置按钮的位置。
问题是,当我运行它时,它会显示:
    The Image

基本上,它甚至不显示按钮 没有错误或任何事情。
有人可以帮我这个吗? (可能只是另一个菜鸟错误)

1 个答案:

答案 0 :(得分:1)

StuffPanel的大小可能是(0,0)