Advanced
There are many advanced features and patterns in ewwii that will help you make your configuration more flexible and powerful. Do note that most of these features and patterns are very simple. don't let the term advanced scare you.
Calling Nbcl Functions
You can run nbcl expressions directly from your terminal using the nbcl-run command as stated in Nbcl Run Advanced Command.
They can be used in ewwii like this:
Button "my-btn" {
label = "Hello, Bob!"
onclick = "ewwii nbcl-run 'change_label()'"
}Make sure you have that function defined in ewwii.nbcl:
# ewwii.nbcl
import core.command
# function must be in ewwii.nbcl
fn change_label() {
command.run("echo 'called' > ~/.local/share/my_program/state.txt")
command.run("notify-send 'called'")
# ... other stuff
# update the property using widget-contorl
# (will be mentioned below)
command.run("ewwii wc property-update --widget 'my-btn' label='Hello, Alice!'")
}Updating Widgets Externally
One of the most powerful features of ewwii is widget-control. It allows ewwii to update, create, remove, widgets directly
from the terminal with a single command. It is quite hard to explain, so it will be ideal to read its documentation
directly from advanced commands.
Button "my-btn" {
label = "Click me!"
onclick = "ewwii wc property-update --widget 'my-btn' label='Surprise!'"
}Using Unsupported Widgets
Ewwii has a special widget called GtkUI that lets you load a widget from a Gtk XML file. Though these widgets cant be updated during runtime, they are a viable option if you want to register a set of static widgets that wont update values.
# Loads a widget with the id 'my-btn'
# from the 'mywidgets.ui' gtk xml file.
GtkUI {
file = "./mywidgets.ui"
id = "my-btn"
}