2

我想知道是否有人可以告诉我如何在提供的代码中添加菜单栏。我的问题是在向 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()
4

1 回答 1

2

菜单栏被添加到框架而不是面板, wxpython 演示有使用菜单栏的示例。

于 2013-08-05T19:30:46.507 回答