How to resize and draw an image using wxpython?

前端 未结 3 653
感动是毒
感动是毒 2020-12-29 11:01

I want to load an image, resize it to a given size and after draw it in a specific position in a panel.

All this using wxpython.

How can I do it?

Tha

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 11:45

    If you mean adding the image to a toolbar / listbook / toolbook etc.. you will have to convert it to a bitmap (usually only bitmaps allowed).

    As far as i know you can't re-size a bitmap, therefore you will have to resize an image before and then convert it.

    Here is a good example http://markandclick.com/1/post/2011/12/wxpython-resize-embedded-bitmap-before-adding-it-as-a-tool.html

    Here is a copy from the example:

    def getFolderBitmap():
      img = folder_icon.GetImage().Rescale(scaleW, scaleH)
      return img.ConvertToBitmap()
    

提交回复
热议问题