主要涉及的知识点
- 在窗口里显示图片
import wx
'''
pip install wxpython
'''
class Frame(wx.Frame):
def __init__(self, image, parent=None, id=-1, pos=wx.DefaultPosition, title='显示图片'):
wx_image = image.ConvertToBitmap()
size = wx_image.GetWidth(), wx_image.GetHeight()
wx.Frame.__init__(self, parent, id, title, pos, size)
self.bmp = wx.StaticBitmap(parent=self, bitmap=wx_image)
class App(wx.App):
def OnInit(self):
image = wx.Image('test.jpg', wx.BITMAP_TYPE_JPEG)
self.frame = Frame(image)
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True
def main():
app = App()
app.MainLoop()
if __name__ == '__main__':
main()