-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jw/newdialogs
- Loading branch information
Showing
50 changed files
with
1,020 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Buttons | ||
|
||
GTK defines many button and button-like widgets. | ||
|
||
## [GtkButton](https://docs.gtk.org/gtk4/class.Button.html) | ||
|
||
We have already encountered the widget `GtkButton`, which defines a "clicked" signal that can be used to let the user trigger callback functions. | ||
|
||
The button holds a child widget that can be a `GtkLabel` in the case of text, an image-displaying widget in the case of an icon, or potentially anything else you want. The child widget can be set and accessed using `getindex(b::GtkButton)` and `setindex!(b::GtkButton, child_widget::GtkWidget)`: | ||
```julia | ||
b = GtkButton() | ||
b[] = my_widget | ||
child_widget = b[] | ||
``` | ||
|
||
You can also associate an action (see [Actions](@ref)) with a button by setting its property "action-name". | ||
|
||
Selected signals: | ||
|
||
| signal | arguments | returns | | | ||
| :--- | :--- | :--- | :--- | | ||
| "clicked" | self::GtkButton | `Nothing` | Emitted when the button is clicked | | ||
|
||
## [GtkToggleButton](https://docs.gtk.org/gtk4/class.ToggleButton.html) | ||
|
||
This widget looks like a button but it stays pressed when the user clicks it. The state of the button can be accessed or set using its property "active", which is `true` when the button is pressed. | ||
|
||
A toggle button can be added to a group using the method `group`, in which case it can be used to select from mutually exclusive options: | ||
```julia | ||
using Gtk4 | ||
|
||
red_button = GtkToggleButton("red") | ||
green_button = GtkToggleButton("green") | ||
blue_button = GtkToggleButton("blue") | ||
win = GtkWindow("choose one color") | ||
win[] = box = GtkBox(:v) | ||
push!(box, red_button) | ||
push!(box, green_button) | ||
push!(box, blue_button) | ||
|
||
group(green_button, red_button) | ||
group(blue_button, red_button) | ||
# now only one button can be active at a time | ||
``` | ||
|
||
Selected signals: | ||
|
||
| signal | arguments | returns | | | ||
| :--- | :--- | :--- | :--- | | ||
| "toggled" | self::GtkToggleButton | `Nothing` | Emitted when the button state is changed | | ||
|
||
|
||
## [GtkCheckButton](https://docs.gtk.org/gtk4/class.CheckButton.html) | ||
|
||
This widget is a checkbox that can be used to control whether something is active (`true`) or inactive (`false`). Functionally it is identical to a `GtkToggleButton` but it is rendered differently. There is typically a label that is rendered next to the checkbox. | ||
|
||
Like a toggle button, a check button can also be added to a group, in which case it is rendered as a "radio button" that can be used to choose from a few mutually exclusive options. | ||
|
||
Selected signals: | ||
|
||
| signal | arguments | returns | | | ||
| :--- | :--- | :--- | :--- | | ||
| "toggled" | self::GtkCheckButton | `Nothing` | Emitted when the button state is changed | | ||
|
||
## [GtkSwitch](https://docs.gtk.org/gtk4/class.Switch.html) | ||
|
||
This widget is very much like a check button but looks like a switch. | ||
|
||
Like `GtkCheckButton`, its "active" property can be used to get and set the switch's state. | ||
|
||
## [GtkLinkButton](https://docs.gtk.org/gtk4/class.LinkButton.html) | ||
|
||
This widget can be used to open a URL: | ||
|
||
```julia | ||
lb = GtkLinkButton("https://julialang.org","Julia website") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Display widgets | ||
|
||
We have already encountered [GtkLabel](@ref), which is used to display text. GTK has a few other widgets that are useful for displaying information. | ||
|
||
## [GtkSpinner](https://docs.gtk.org/gtk4/class.Spinner.html) | ||
|
||
This is a simple widget that optionally shows an animated spinning icon. It's used to indicate to the user that something is happening. | ||
|
||
The widget is constructed using `GtkSpinner()`. There are just two methods, `start` to display the spinning icon and `stop` to not display it. | ||
|
||
To check if the spinner is spinning, use the "spinning" property or the `spinning` getter method. | ||
|
||
## [GtkProgressBar](https://docs.gtk.org/gtk4/class.ProgressBar.html) | ||
|
||
This widget shows a progress bar and optionally text. | ||
|
||
```julia | ||
win = GtkWindow("Progress bar") | ||
progbar = GtkProgressBar() | ||
push!(win, progbar) | ||
``` | ||
|
||
The fractional progress (between 0.0 and 1.0) can be set using the `fraction` setter or the "fraction" property: | ||
```julia | ||
fraction(progbar, 0.5) | ||
progbar.fraction | ||
``` | ||
|
||
You can show text which might, for example, say something about what is happening or an estimated time left: | ||
```julia | ||
Gtk4.text(progbar, "11 seconds remaining") | ||
``` | ||
|
||
For processes with no well defined concept of progress, you can periodically use the `pulse` method to cause the progress bar to show a back and forth motion (think "Knight Rider"), reassuring the user that something is continuing to happen: | ||
|
||
```julia | ||
Gtk4.pulse(progbar) # moves the progress bar a little | ||
``` | ||
|
||
The step size (in fractional units) for `pulse` can be set using `Gtk4.pulse_step`. | ||
|
||
## [GtkPicture](https://docs.gtk.org/gtk4/class.Picture.html) and [GtkImage](https://docs.gtk.org/gtk4/class.Image.html) | ||
|
||
These two widgets can be used to display an image. `GtkPicture` shows the image at its natural size, while `GtkImage` shows it at a fixed, potentially smaller size (for example, an icon). The image can be set in a constructor or be set by a method. | ||
|
||
For `GtkPicture`, there are constructors that read from a file (in PNG, JPEG, or TIFF format), either using a `GFile` object or a filename. Alternatively you can construct a `GtkPicture` from a `GdkPixbuf` or `GdkPaintable`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.