beetlebug

ztk::class

Reads and changes the style classes of a widget, for the selectors of a stylesheet.

Synopsis

ztk::class PATH
ztk::class PATH add ?NAME ...?
ztk::class PATH remove ?NAME ...?
ztk::class PATH set ?NAME ...?

Arguments

Name Type Default Meaning
PATH widget path The widget. With no other word, the command gives its classes.
add NAME ... subcommand Adds each class that the widget does not have, at the end.
remove NAME ... subcommand Removes each class. A class that the widget does not have is no error.
set NAME ... subcommand Replaces the classes with the names. No name removes each class.

A class big matches the selector .big, such as Button.big.

Return value

ztk::class PATH gives the list of the classes, in their order. The subcommands give an empty string.

Errors

Error When
bad window path name "W" No widget has the name.
bad option "X": must be add, remove, or set An unknown subcommand.

Platforms

Platform Works
Windows Yes
macOS Yes
Linux, Wayland Yes
Linux, X11 Yes
Web Yes
iOS, Android Yes
Headless Yes

Example

button .go -text Go
pack .go
ztk::class .go add big primary
ztk::class .go remove primary
ztk::class .go

See also