Path for widgets icons

I experiencing troubles trying to set the path for widget icons, meaning I don’t know the rules to set the path for a resource.
I would like to assign an icon to a button, the structure of my app is:
/
assets/main-view.xml
resources/icons/*.png
src/main.hx & mainView.hx

Inside main-view.xml I declared a button:

<button id="btnHashResultCopy" width="32" icon="resources/icons/edit-copy.png" style="padding:5px;" />

It doesn’t load and show any image inside the button. I’m sure I’m doing something wrong but I wasn’t able to find any info about the path usage. Can anyone help me?

Ok, it seems that the icon is correctly present inside the build folder and seen by the program (I got the confirm using FileSystem.exist) but the icons are not presented inside the buttons. Is this a limitation from HxWidgets (while wxWidgets permit the usage of icons in buttons)?

I think icons work in hxwidgets …
to set your resources you have to modify module.xml to add them there maybe do you have a module.xml ?

I added the following lines in my hxwidgets.hxml:

--cmd mkdir -p build/hxwidgets/resources/icons
--cmd cp -r resources/* build/hxwidgets/resources/

Folders are created and filled up with icons but I’m not able to get the GUI load them inside the widgets.

yeah that’s not how you do it

there are two types of path

  • resources but haxe ui must know about it.
    to use resources … haxeui must know about it.
    you must create a module.xml in the src folder in there aren’t any
    and add
<module>
    <resources>
        <resource path="resources" prefix="resources" />
    </resources>
</module>
  • external link with file:// I think
<button id="btnHashResultCopy" width="32" icon="file://resources/icons/edit-copy.png" style="padding:5px;" />

I have to be honest, documentation lacks a lot of information. I obtained the code in my first post using Copilot… Now I see that there are other things to know but I don’t know where they came from, to be honest.

yeah it’s true haxeui lacks a lot of documentation as in official documentation ( it’s basically a one man work)
it’s better to look at the code / at the forum / at discord
component builder is great too …

And even for the parts that are well documented … not sure llms know really much about them.
So continue to ask questions :slight_smile: Haxeui is not complex there are few things to know and once you know them it will be easy to guess the rest.

But yeah modules.xml is important to know it’s where you define the settings haxeui haxeui-core/haxe/ui/module.xml at master · haxeui/haxeui-core · GitHub you can define new locales themes etc …

I discovered another issue/bug/problem…
I’m just trying to give menu items some fancy icons but simply they don’t appear. I notice that the menus example in the components explorer shows the same bug:
https://haxeui.org/explorer/#containers/menus
Look at the “Icons” menu: it doesn’t show any icon, but the code says the opposite:

<menuitem text="Item 1" icon="icons/16/scroll_pane_text.png" shortcutText="Ctrl+A" />

I thought it was a bug in HTML5 but I get the same issue when compiling on my Linux box. It seems that the entry “icon” is ignored…

Actually it seems the reason Builder - HaxeUI is the paths don’t really exist.
Now I don’t this will work on hxwidgets… hxwidgets is far more limited.

This is what i meant when i said that the documentation is lacking…
Apart from that, thank you for all the help you are giving me.

(very) late to the party :confused:

But for completeness ill answer (super sorry for the crazy late upkeep of this forum!):

so icons in menus should work fine, my guess is your resources are “right”… do the icons show correctly in, say, a button? This seems to work for me:

<vbox width="100%" height="100%">
    <menubar width="100%">
        <menu text="Menu">
            <menu-item text="Item 1" icon="haxeui-core/styles/shared/info-small.png" />
            <menu text="Item 2" icon="haxeui-core/styles/shared/help-small.png" >
                <menu-checkbox text="Check 1" />
                <menu-checkbox text="Check 2" selected="true" />
                <menu-checkbox text="Check 3" />
                <menu-separator />
                <menu-optionbox text="Option 1" />
                <menu-optionbox text="Option 2" selected="true" />
                <menu-optionbox text="Option 3" />
                <menu-separator />
                <menu-item text="Item 2A" icon="haxeui-core/styles/shared/help-small.png" />
                <menu-item text="Item 2B" icon="haxeui-core/styles/shared/help-small.png" />
                <menu-item text="Item 2C" icon="haxeui-core/styles/shared/help-small.png" />
            </menu>
            <menu-item text="Item 3" icon="haxeui-core/styles/shared/warning-small.png" />
        </menu>    
    </menubar>
</vbox>

do you get different results?

Cheers,
Ian

Thanks for your reply. I don’t know where to store the icons to use on the menu. If I try to integrate your piece of code in my app, I get the usual result of all times I run my app, i.e. icons not showing in the menu items.


This is the structure of my app:

I also copy icons, during compiling, inside the project. This is my hxwidgets.hxml file:

-cp src
-main Main

-lib haxeui-core
-lib haxeui-hxwidgets
-lib hxWidgets
-lib random
-lib crypto

-D ABI=-MD
-D WXSTATIC
-D DEBUG

-cpp build/hxwidgets
--cmd mkdir -p build/hxwidgets/resources/icons
--cmd cp -r resources/* build/hxwidgets/resources/

As suggested in a previous post, I created a module.xml file with this code to instruct the compiler where to get the icons with prefix ‘icons’ from:

<module id="hxcrypto">
    <resources>
        <resource path="/resources/icons" prefix="icons" />
    </resources>
</module>

I think it’s correct since the buttons retrieve their icons with a similar code and they show their icons:

<button id="clearfileBtn" icon="icons/clear.png" width="32" height="32" />

PS: as you can see, icons in the buttons are truncated: I’m not able to use them in their correct dimensions, even though I resize them to be smaller than the buttons.

the fact that haxeui-core/styles/shared/info-small.png doesnt work indicates something else is going on, since these are 100% embedded into the resulting application, i seem to remember making a comment somewhere in the source about a difference in linux. Ill see if i can find it, do any of your other native applications have menu icons?

Cheers,
Ian

/*
Note: Images in buttons for ubuntu dont work until you run:
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/ButtonImages': <1>, 'Gtk/MenuImages': <1>}"
*/

Thank you for your reply, but I’m using Manjaro Linux (based on Arch) and KDE as my desktop environment, and the command you suggested to me doesn’t work because my Linux box isn’t based on Gnome.

i guess maybe try something of this (chatgpt) to see if it helps:


1. Make sure KDE is set to show menu icons

KDE Plasma 5 / 6

  1. Open System Settings
  2. Go to:
Appearance → Icons
  1. Enable:
    :heavy_check_mark: Show icons in menus

Apply and log out / log back in (important).

This is the most common fix on KDE.


2. Verify the Plasma style isn’t suppressing menu icons

Some Plasma styles ignore the global setting.

Check:

System Settings → Appearance → Application Style

Try switching temporarily to:

  • Breeze
  • Breeze Classic

If icons appear after switching → your previous style is suppressing them.


3. wxWidgets build must use GTK (not Qt)

On Linux, wxWidgets does not use Qt, even on KDE.
It uses GTK — and GTK honors KDE settings only if the GTK platform theme is set correctly.

Check your wxWidgets port

Run:

wx-config --selected-config

You should see something like:

gtk3-unicode

If you see:

  • gtk2 → upgrade to GTK3
  • base → menus/icons won’t show

4. Ensure GTK apps follow KDE settings (VERY important)

If GTK apps don’t respect KDE settings, wxWidgets menus won’t either.

Install KDE GTK integration

On Manjaro:

sudo pacman -S breeze-gtk

Then:

System Settings → Appearance → Application Style → Configure GNOME/GTK Application Style

Set:

  • GTK theme: Breeze
  • Icons: Breeze
  • Show icons in menus: enabled

Log out and back in.


5. Test with a GTK app (sanity check)

Run a GTK app that has menu icons, e.g.:

gedit

If gedit menus show icons, wxWidgets can too.
If they don’t → the problem is GTK/KDE integration, not wxWidgets.