0

I am trying to add icons to my menu options in wxpython. I have followed the code here but my image displays really large (not the nice icons size that Mike shows). Here is my code -- is there a way to make the icon fit the menu size (resize it)? Thanks!

self.HelpMenu = wx.Menu()

self.HelpAboutItem2 = wx.MenuItem(self.HelpMenu, 202, "&Visit Us", "Go to our website", wx.ITEM_NORMAL)
img = wx.Image('My_Image.jpg', wx.BITMAP_TYPE_ANY)
self.HelpAboutItem2.SetBitmap(wx.BitmapFromImage(img))
self.HelpMenu.AppendItem(self.HelpAboutItem2)

self.SetMenuBar(self.MainMenu)

1 Answer 1

1

I think I saved my image in a specific size for that particular example. I'm not finding anything in wx.Menu that let's you specify a size. However, wx.Image has Scale and Rescale methods that you might be able to use for scaling the image on the fly. I used that method in my image viewer tutorial to keep images from becoming too big for my screen.

Sign up to request clarification or add additional context in comments.

2 Comments

I liked that other tutorial -- I use that quite a bit. Do you know the size you saved your image for the menu?
Looks like it's 32x27. I thought it might be something like that. Most icons for toolbars are 22x22 or 32x32 when you download an icon set. I've found myself using that tutorial myself from time to time. I used that scaling method for logos in Reportlab even!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.