大哥们,小弟初学python,急着用图片上传,请问谁知道怎么写上传()
如何在python界面显示图片
代码:# show a jpeg (.jpg) image using wxPython, newer coding style# two different ways to load and display are given# tested with Python24 and wxPython25vegaseat24jul2005import wximport cStringIOclass Panel1(wx.Panel):""" class Panel1 creates a panel with an image on it, inherits wx.Panel """def __init__(self, parent, id):# create the panelwx.Panel.__init__(self, parent, id)try:# pick a .jpg file you have in the working folderimageFile = Moo.jpgdata = open(imageFile, "rb").read()# convert to a data streamstream = cStringIO.StringIO(data)# convert to a bitmapbmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))# show the bitmap, (5, 5) are upper left corner coordinateswx.StaticBitmap(self, -1, bmp, (5, 5))# alternate (simpler) way to load and display a jpg image from a file# actually you can load .jpg .png .bmp or .gif filesjpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()# bitmap upper left corner is in the position tuple (x, y) = (5, 5)wx.StaticBitmap(self, -1, jpg1, (10 + jpg1.GetWidth(), 5), (jpg1.GetWidth(), jpg1.GetHeight()))except IOError:print "Image file %s not found" % imageFileraise SystemExitapp = wx.PySimpleApp()# create a window/frame, no parent, -1 is default ID# increase the size of the frame for larger imagesframe1 = wx.Frame(None, -1, "An image on a panel", size = (400, 300))# call the derived clasSPAnel1(frame1,-1)frame1.Show(1)app.MainLoop()