Wxpython image display-Hello wxpython

Source: Internet
Author: User

All the examples shown are from wxpython in action. Only my annotations are added.

 #  ! /Usr/bin/Python  #  -*-<Coding = UTF-8> -*-  """  Hello, wxpython! Program.  """  Import  WX  Class  Frame (wx. Frame ):  """  Create a subclass of Wx. Frame  """      Def  _ Init __ (Self, image, parent = none, id =-1, Pos = wx. defaultposition, Title = "  Hello, wxpython!  "  ):  """  In _ init _, which parameters are required? Who can remember each time there are so many parameters. however, parameters do not have order requirements. think about what is required to create a frame, such as position, size, title, and ID.  """          #  Convert to BMP for easy processing Temp = Image. converttobitmap ()  #  Obtains the image size and uses it as the frame size. Size =Temp. getwidth (), temp. getheight () WX. Frame.  _ Init __  (Self, parent, ID, title, POs, size)  #  You can see staticbitmap (parent = self), where self points to frame, so the image is displayed on the frame.      #  If you want to modify the parent if you want to create a panel in the frame, try it.      #  Note the difference between the two sentences because the parent parameters are different. After running, you can see that if you draw a picture on the frame, it will be covered by the Panel.      #  If you draw a picture on a panel, there will be no problems, or you will not create a panel, or draw a picture on a frame. To some extent, you can understand some of the meanings of self. Panel = wx. Panel (self,-1 ) WX. staticbitmap (parent = Self, bitmap = Temp) WX. staticbitmap (parent = Panel, bitmap = Temp)  Class  APP (wx. app ):  Def  Oninit (Self): Image = Wx. Image ( "  Filezilla.png  "  , Wx. bitmap_type_png) self. Frame = Frame (image) self. Frame. Show () self. settopwindow (self. Frame)  Return  True Def  Main (): app = APP () app. mainloop ()  If   _ Name __ = "  _ Main __  "  : Main () 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.