If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
SetBitmap segfaults every time. The didit stuff is because there is a loop and I wanted to isolate the problem by appending a bitmap only once. wxGTK 3.0.4
I also tried incorporating wxlog.xpm into the file instead of referencing the file name.
Is there an example somewhere of attaching a bitmap from a file? Even if the file is read into memory. Linux only.
The "menu" sample shows how to do it. There is not much that can go wrong here. If it's really the SetBitmap() call that crashes, either the wxMenuItem pointer is invalid or the bitmap. Before using the bitmap, use wxBitmap::IsOk() to check if it was loaded successfully.
What's the context of this line? If it's a global variable, it won't work, because the image handlers are not yet initialized when this variable is created. You must call ::wxInitAllImageHandlers() before you can load any bitmap.
doublemax wrote: ↑Wed Jun 23, 2021 5:32 am You must call ::wxInitAllImageHandlers()
This solved the crash. But the icons are still not appearing on the button. Maybe a button was the wrong metaphor.
I'm trying to create a panel with a toolbar and a button that launches applications like the "Applications" button om Mate-panel and gnome-panel
but without all the bells and whistles like dbus messages. It's working fine now except the menu has no icons, only text. Maybe a toolbar was not the right widget.
I want to create a panel with a menu that has icons next to it. Like the Quit menu in this example: https://zetcode.com/gui/wxwidgets/menustoolbars/
Perhaps the menu need not be on a button. Only the title is visible until the button is clicked. Perhaps that is standard for a wxmenu. I've been searching the web for an example but can't find one there. Mate, Gnome, XFCE have such panels
The menus look like the Firefox "History" button/menu but mine don't show the icon but should.
The "Quicklinks" button on this forum is another example.
I checked the sample. I #include'd "wxlogo.xpm" and Appended wxlogo_xpm per the sample. It compiled fine and ran fine, but no logo icon.
Is it the size of the icon? Most of what i want to use is png Don't they resize? Maybe i should try a huge panel.
Tony0945 wrote: ↑Fri Jun 25, 2021 1:00 am
I checked the sample. I #include'd "wxlogo.xpm" and Appended wxlogo_xpm per the sample. It compiled fine and ran fine, but no logo icon.
Is it the size of the icon? Most of what i want to use is png Don't they resize? Maybe i should try a huge panel.
You mean you modified the sample code, you changed on of the bitmaps in a sample to display your bitmap and it still doesn't show?
Did you place the bitmap in the same directory as all other ones?
Was it successfully loaded?