wxpython->图片显示不完整
wxpython->图片显示不完整
主要是运行后显示的图片仿佛边缘被裁减过的样子。谁能解释一下原因?
#!/usr/bin/env python"""Hello, wxPython! program."""import wxclass Frame(wx.Frame): """Frame class that displays an image.""" def __init__(self, image): """Create a Frame instance and display image.""" temp = image.ConvertToBitmap() size = temp.GetWidth(), temp.GetHeight() wx.Frame.__init__(self, parent=None, id=-1, title='Hello, wxPython!', pos=wx.DefaultPosition,size=size) self.panel = wx.Panel(self) wx.StaticBitmap(parent=self.panel, bitmap=temp) self.Centre() class App(wx.App): """Application class.""" def OnInit(self): image = wx.Image('img.jpg', wx.BITMAP_TYPE_JPEG) self.frame = Frame(image) self.frame.Show() self.SetTopWindow(self.frame) return Truedef main(): app = App() app.MainLoop()if __name__ == '__main__': main()
def __init__(self, image): """Create a Frame instance and display image.""" temp = image.ConvertToBitmap() #~ size = temp.GetWidth(), temp.GetHeight() wx.Frame.__init__(self, parent=None, id=-1, title='Hello, wxPython!')#, pos=wx.DefaultPosition,size=size) #~ pos=wx.DefaultPosition,size=size) self.panel = wx.Panel(self) wx.StaticBitmap(parent=self.panel, bitmap=temp) sizer = wx.BoxSizer() sizer.Add(self.panel, 1, wx.EXPAND) self.SetSizerAndFit(sizer) self.Centre()