# Where do I find the GTK widget properties?

**URL:** https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299
**Category:** General Usage
**Tags:** gtk
**Created:** [April 30, 2022, 4:41pm UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299 "2022-04-30T16:41:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [April 30, 2022, 4:41pm UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/1 "2022-04-30T16:41:33Z")

</div>

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:

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

```

obtaining this warnig:

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

```

Thanks

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [May 1, 2022, 12:53am UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/2 "2022-05-01T00:53:35Z")

</div>

Unfortunately, the documentation is very sparse. I scoured the unit tests and source code, and also cross referenced the GTK documentation [here](https://www.gtk.org/docs/).

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [May 1, 2022, 7:19am UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/3 "2022-05-01T07:19:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [May 1, 2022, 7:31pm UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/4 "2022-05-01T19:31:41Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

### Author: ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)
#### Post date: [December 7, 2022, 11:12pm UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/5 "2022-12-07T23:12:43Z")

</div>

`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
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)

```

---

<div class="post-metadata">

### Author: ![Rossati](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rossati/32/44973_2.png) [@Rossati](https://discourse.julialang.org/u/Rossati)
#### Post date: [December 8, 2022, 8:56am UTC](https://discourse.julialang.org/t/where-do-i-find-the-gtk-widget-properties/80299/6 "2022-12-08T08:56:03Z")

</div>

Thanks Lilith
