【问题标题】:Wigets inside of second panel dissapear第二个面板内的小部件消失了
【发布时间】:2018-08-01 19:06:25
【问题描述】:

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

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

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

基本上,它甚至不显示按钮。
没有错误或任何东西。
有人可以帮我解决这个问题吗?
(可能只是另一个新手错误)

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-03-29
      • 2011-10-17
      • 1970-01-01
      • 2012-12-25
      • 1970-01-01
      • 2022-11-01
      • 2019-11-27
      • 2014-06-02
      • 2011-02-01
      相关资源
      最近更新 更多