Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add slider (GtkScale) example #638

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ makedocs(
"manual/keyevents.md",
"manual/canvas.md",
"manual/customWidgets.md",
"manual/slider.md",
"manual/async.md",
"manual/nonreplusage.md",
"manual/packages.md"
Expand Down
36 changes: 36 additions & 0 deletions docs/src/manual/slider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Slider widgets (aka GtkScale) and dynamic adjustments

The following example
creates two sliders using `GtkScale`.
The callback function for the 1st slider
dynamically changes the value of the 2nd slider
to force it to match,
and also dynamically changes the range of the 1st slider
if the value reaches 10.

This example illustrates
that one can use `GAccessor.value`
both to _access_ a widget value and to _alter_ that value.

```julia
using Gtk: GtkGrid, GtkScale, GtkWindow, GAccessor
using Gtk: signal_connect, set_gtk_property!, showall

win = GtkWindow("Sliders", 500, 200)
slider1 = GtkScale(false, 0:10)
slider2 = GtkScale(false, 0:30)
signal_connect(slider1, "value-changed") do widget, others...
value = GAccessor.value(slider1)
GAccessor.value(slider2, value) # dynamic value adjustment
println("slider value is $value")
if value == 10
GAccessor.range(slider1, 1, 20) # dynamic range adjustment
end
end
g = GtkGrid()
g[1,1] = slider1
g[1,2] = slider2
set_gtk_property!(g, :column_homogeneous, true)
push!(win, g)
showall(win)
```