带有菜单栏的wx.Panel

时间:2013-08-05 19:15:21

标签: python wxpython

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

1 个答案:

答案 0 :(得分:2)

菜单栏添加到框架而非面板中,wxpython演示中包含使用菜单栏的示例。