我想知道是否有人可以向我展示如何在提供的代码中添加菜单栏。我的问题是我找不到向wx.panel添加菜单栏的任何文档或任何内容。这有可能吗?如果你能告诉我那会是多么棒。这是我的代码:

class Panel1(wx.Panel):
def __init__(self, parent, id):
# create the panel
    wx.Panel.__init__(self, parent, id)
    try:
        imageFile = 'resize.jpg'
        data = open(imageFile, "rb").read()

        stream = cStringIO.StringIO(data)

        bmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))
        weather1 = "The current temp in Urbandale is %r" % (ob['tempF'])
        weather2 = "With the heat index the temp in Urbandale is %r" % (ob['heatindexF'])
        wx.StaticBitmap(self, -1, bmp, (0, 0))
        if ob['tempF'] >= '80':
            label2 = wx.StaticText(self, -1, weather1 , wx.Point(20, 196))
        if ob['tempF'] <= '90':
            label2 =  wx.StaticText(self, -1, weather2 , wx.Point(20, 196))
        label2.SetBackgroundColour("white")
        jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()

        wx.StaticBitmap(self, -1, jpg1, (10 + jpg1.GetWidth(), 5), (jpg1.GetWidth(), jpg1.GetHeight()))
    except IOError:
        print "Image file %s not found" % imageFile
        raise SystemExit

app = wx.PySimpleApp()
frame1 = wx.Frame(None, -1, "Weather", size = (316, 435))
Panel1(frame1,-1)
frame1.Show(1)
app.MainLoop()

最佳答案

菜单栏被添加到“框架”而不是“面板”中。wxpython演示包含使用菜单栏的示例。

关于python - wx.Panel带菜单栏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18065922/

10-13 09:18