def next_keyboard(self):
        """set the next layout in the list of configured keyboard layouts as
        new current layout in use

        If the current keyboard layout is not in the list, it will set as new
        layout the first one in the list.
        """

        current_keyboard = self.backend.get_keyboard()
        if current_keyboard in self.configured_keyboards:
            # iterate the list circularly
            next_keyboard = self.configured_keyboards[
                (self.configured_keyboards.index(current_keyboard) + 1)
                % len(self.configured_keyboards)
            ]
        else:
            next_keyboard = self.configured_keyboards[0]

        self.backend.set_keyboard(next_keyboard, self.option)

        self.tick()
set the next layout in the list of configured keyboard layouts as
        new current layout in use

        If the current keyboard layout is not in the list, it will set as new
        layout the first one in the list.
        
libqtile/widget/keyboardlayout.py