Search code examples
pythonpython-3.xuser-interfacewxwidgets

Wigets inside of second panel dissapear


This is a "part two" to this question.
So I have this (same) code:

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()

And override_contents:

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()
    }
]

So i'm trying to use two panels, panel and StuffPanel.
panel is the main panel, and StuffPanel is where the buttons are being put at.
The problem is that when I run it, it displays this:
The Image

Basicly, it doesn't even display the buttons.
No error or anything.
Can someone please help me on this?
(Probably just another rookie mistake)


Solution

  • Most probably the size of your StuffPanel is (0,0).