Skip to content

cycle between widgets on mouse click. #2857

Answered by elParaguayo
Sydiepus asked this question in Q&A
Discussion options

You must be logged in to vote

You don't need the WidgetBox for this. A mouse_callback should be ok. Something like this:

from libqtile import qtile

def toggle_clock():
    time_format = '%I:%M %p'
    date_format = '%m-%d %a'

    # Get the clock widget
    clock = qtile.widgets_map["clock"]

    # Look for an attribute called "_toggled" which we'll use to track the state
    if getattr(clock, "_toggled", False):
        # if it's not "toggled" then change to the date format and set the flag
        clock.format = date_format
        clock._toggled = True
    else:
        # otherwise, change back to the time format
        clock.format = time_format
        clock._toggled = False

    # This may change the widget le…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Sydiepus
Comment options

@elParaguayo
Comment options

@Sydiepus
Comment options

Answer selected by Sydiepus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants