Where do I find the GTK widget properties?

Hi
I started using Julia to build a form generator by GTK and I haven’t find a list of widget properties so, for example, for set the button width. I have tried this:

function createButton(caption,width)
        btn = GtkButton(caption)
        set_gtk_property!(btn, :width,width)
        return btn
end
...
ok = createButton("Ok",70)

obtaining this warnig:

g_object_set_is_valid_property: object class 'GtkButton' has no property named 'width'

Thanks

Unfortunately, the documentation is very sparse. I scoured the unit tests and source code, and also cross referenced the GTK documentation here.

Thanks

I hadn’t seen this documentation yet.
On first examination it would seem (perhaps) that the solution is CSS. I try to investigate this.

Hello
I was able to set some button properties (text color, border), but not width:

function createButton(name,caption,width)
        btn = GtkButton(caption)
        sc = GAccessor.style_context(btn)
        pr = CssProviderLeaf(data="#$name {background:olive;border-width:10px}")
        push!(sc, StyleProvider(pr), 600)
        set_gtk_property!(btn, :name, caption)
        return btn

set_gtk_property!(b, :width_request, 1000) is probably what your are looking for. The widgit properties are all printed when a widget is displayed as text at the REPL. This is a REPL session where I found it:

julia> using Gtk

julia> b = GtkBu
GtkBuildable      GtkBuilder        GtkBuilderLeaf    GtkButton         GtkButtonBox      GtkButtonBoxLeaf  GtkButtonLeaf
julia> b = GtkButton()
GtkButtonLeaf(action-name=NULL, action-target, related-action, use-action-appearance=TRUE, name="", parent, width-request=-1, height-request=-1, visible=FALSE, sensitive=TRUE, app-paintable=FALSE, can-focus=TRUE, has-focus=FALSE, is-focus=FALSE, focus-on-click=TRUE, can-default=FALSE, has-default=FALSE, receives-default=TRUE, composite-child=FALSE, style, events=0, no-show-all=FALSE, has-tooltip=FALSE, tooltip-markup=NULL, tooltip-text=NULL, window, opacity=1.000000, double-buffered, halign=GTK_ALIGN_FILL, valign=GTK_ALIGN_FILL, margin-left, margin-right, margin-start=0, margin-end=0, margin-top=0, margin-bottom=0, margin=0, hexpand=FALSE, vexpand=FALSE, hexpand-set=FALSE, vexpand-set=FALSE, expand=FALSE, scale-factor=2, border-width=0, resize-mode, child, label=NULL, image, relief=GTK_RELIEF_NORMAL, use-underline=FALSE, use-stock, xalign, yalign, image-position=GTK_POS_LEFT, always-show-image=FALSE)

julia> # Notice that width-request=-1 appears in this list /\

julia> set_
set_coordinates      set_gtk_property!    set_source           set_source_rgba      set_zero_subnormals
set_dash             set_line_width       set_source_rgb       set_theme
julia> set_gtk_property!(b, :width_request, 1000)
GtkButtonLeaf(action-name=NULL, action-target, related-action, use-action-appearance=TRUE, name="", parent, width-request=1000, height-request=-1, visible=FALSE, sensitive=TRUE, app-paintable=FALSE, can-focus=TRUE, has-focus=FALSE, is-focus=FALSE, focus-on-click=TRUE, can-default=FALSE, has-default=FALSE, receives-default=TRUE, composite-child=FALSE, style, events=0, no-show-all=FALSE, has-tooltip=FALSE, tooltip-markup=NULL, tooltip-text=NULL, window, opacity=1.000000, double-buffered, halign=GTK_ALIGN_FILL, valign=GTK_ALIGN_FILL, margin-left, margin-right, margin-start=0, margin-end=0, margin-top=0, margin-bottom=0, margin=0, hexpand=FALSE, vexpand=FALSE, hexpand-set=FALSE, vexpand-set=FALSE, expand=FALSE, scale-factor=2, border-width=0, resize-mode, child, label=NULL, image, relief=GTK_RELIEF_NORMAL, use-underline=FALSE, use-stock, xalign, yalign, image-position=GTK_POS_LEFT, always-show-image=FALSE)
2 Likes

Thanks Lilith