For a small application I would like to show an image (300 * 200 approx in size) and a small piece of text below it. The image is a thumbnail of a movie and the text is the title. By googling I found out that wx.Button could show both an image and a label and I collected some sample code. In my first sample code an image is shown. However, when a label is specified the label is shown without the image.
I’m using the latest version of wxPython (4.*),latest version of Python (3.9) on an Ubuntu 20.04 desktop. My testcode is simple and straightforward without putting pieces of code in classes but this is IMO not relevant right now.
Could someone please have a look what I am missing?
import wx app = wx.App() frame = wx.Frame(None, -1, "") frame.SetDimensions (0, 0, 500, 500) panel = wx.Panel(frame, wx.ID_ANY) # # shrink camping.png to 300 * 200 # bitmap = wx.Bitmap("camping.png", wx.BITMAP_TYPE_ANY) image = wx.ImageFromBitmap(bitmap) image = image.Scale(300, 200, wx.IMAGE_QUALITY_HIGH) result = wx.BitmapFromImage(image) # # button with label does not show the image # #button = wx.Button(panel, wx.ID_ANY, "Camping Life", (0,0), (400,400)) #button.SetBitmap(result,wx.TOP) # # button without label does show the image # button = wx.Button(panel, wx.ID_ANY, "", (0,0), (400,400)) button.SetBitmap(result,wx.TOP) # frame.Show() app.MainLoop()