这是"第二部分"到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()
}
]
所以我试图使用两个面板,panel
和StuffPanel
panel
是主面板,StuffPanel
是放置按钮的位置。
问题是,当我运行它时,它会显示:
The Image
基本上,它甚至不显示按钮
没有错误或任何事情。
有人可以帮我这个吗?
(可能只是另一个菜鸟错误)
答案 0 :(得分:1)
StuffPanel
的大小可能是(0,0)
。