Skip to content

Clock Widget

Dan edited this page Feb 13, 2022 · 2 revisions

The widget yasb.clock.ClockWidget displays the current date and time, allows for cycling between different time-zones, and alternating between datetime formats.

Configuration

type: "yasb.clock.ClockWidget"

Options:

option type default description
label str {%H:%M:%S} The label format of the widget. Accepts a string with valid python datetime format enclosed between curly brackets.
label_alt str {%d-%m-%y %H:%M:%S} The alternate label format of the widget. See above for datetime format options.
update_interval int 1000 The interval at which the widget will update itself. Accepts a positive integer representing the timeout period between clock update cycles (milliseconds).
timezones list[str] [] A list of cycle-able time-zones. Accepts a list of time-zone strings e.g. ["Europe/London", "America/New_York"]
callbacks dict[str] see callbacks Left, middle and right-click widget behaviour.

Callbacks

Default Callbacks
callback type default description
on_left str "toggle_label" Action triggered when the widget is left-clicked.
on_middle str "do_nothing" Action triggered when the widget is middle-clicked.
on_right str "next_timezone" Action triggered when the widget is right-clicked.
Callback Options
  • "toggle_label" - toggles between label and label_alt formats
  • "next_timezone" - cycles the next time-zone specified in timezones list
  • "do_nothing" - does nothing

Example:

example-clock-widget:
    type: "yasb.clock.ClockWidget"
    options:
        label: "{%H:%M:%S}"
        label_alt: "{%d-%m-%y %H:%M:%S}"
        update_interval: 1000
        timezones: []
        callbacks:
            on_left: "toggle_label"
            on_middle: "do_nothing"
            on_right: "next_timezone"

CSS Class Selectors

  • .clock-widget
    • .label
    • .label-alt