I have a folder containing a number of .jpg
files (each of them are 100x100 pixels).
I would like to create a wxPython
panel showing all these .jpg
(with a mosaic layout) as wx.BitmapButton
.
I tried with the wxPython's demo called BitmapButton.py
but this loads images from embedded image only, here I don't know what's the canonical way to do it with JPEGs.
Moreover, I would like this panel to automatically give a good disposition of the buttons.
Example : let's assume I have 10 buttons.
How to deal with JPEGs in wx.BitmapButton
, and if many buttons, how to make that they have automatically a good layout in the panel (auto alignement in rows) ?
Yes, there is a new sizer that can do what you want in wxPython 2.9+ called WrapSizer. There is an example of its usage in the wxPython demo. You can also read about it at the following:
As for the BitmapButton, I am pretty sure you can pass it a jpg file if you do it properly. You will probably need to do something like this:
img = wx.Image(filepath, wx.BITMAP_TYPE_ANY)
bmp = wx.BitmapFromImage(img)
b = wx.BitmapButton(self, -1, bmp, (20, 20),
(bmp.GetWidth()+10, bmp.GetHeight()+10))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.