Change Gtk.jl button icon

kobied
Wed, 19 Aug 2020 06:37:38 +0000
General Usage

hello,
i’m building a GUI using Gtk.jl and i need to change a button icon once pressed.
To create the button with an icon i use:

rec_icon = load(img_path)
rec_btn = Button(Image(Pixbuf(data=rec_icon, has_alpha=false)))

at this point if i push the button to a windows it works fine. next i want to change the icon of the button, to do so i call:

rec_icon = load(new_img_path)
set_gtk_property!(rec_btn, :image, Pixbuf(data=rec_icon, has_alpha=false))

but the icon in the GUI window does not change…

this is the full test code:

rec_icon = load(img_path)
rec_btn = Button(Image(Pixbuf(data=rec_icon, has_alpha=false)))

win = GtkWindow("Composed Widget",800,600)
push!(win, rec_btn)
showall(win)

rec_icon = load(new_img_path)
set_gtk_property!(rec_btn, :image, Pixbuf(data=rec_icon, has_alpha=false))

thank

1 post - 1 participant