elParaguayo / qtile-extras

Somewhere to store things I create for qtile that probably won't end up in the official repo
MIT License
163 stars 19 forks source link

Tooltips not working when added to wallpaper widget #347

Closed DeeeeLAN closed 3 months ago

DeeeeLAN commented 3 months ago

I have a handful of custom widgets with tooltips mixed in, including various graph widgets and the wallpaper widget. Tooltips are working fine for the graphs but when I hover over the wallpaper widget, I get the following error:

AttributeError: 'NoneType' object has no attribute 'create_layout'
2024-05-30 10:45:11,925 ERROR libqtile base.py:_wrapper():L397 got exception from widget timer
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/libqtile/widget/base.py", line 395, in _wrapper
    method(*method_args)
  File "/usr/lib/python3.12/site-packages/qtile_extras/widget/mixins/__init__.py", line 156, in _show_tooltip
    self._tooltip.clear()
  File "/usr/lib/python3.12/site-packages/libqtile/popup.py", line 140, in clear
    self.drawer.clear(self.background)
  File "/usr/lib/python3.12/site-packages/libqtile/backend/base/drawer.py", line 316, in clear
    self.clear_rect()
  File "/usr/lib/python3.12/site-packages/libqtile/backend/x11/drawer.py", line 234, in clear_rect
    with cairocffi.Context(self._xcb_surface) as ctx:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/cairocffi/context.py", line 100, in __init__
    self._init_pointer(cairo.cairo_create(target._pointer))
                                          ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_pointer'

Here is my wallpaper widget class:

from libqtile.widget.wallpaper import Wallpaper
from qtile_extras.widget.mixins import TooltipMixin

class ToolTipWallpaper(Wallpaper, TooltipMixin):

    def __init__(self, *args, **kwargs):
        Wallpaper.__init__(self, *args, **kwargs)
        TooltipMixin.__init__(self)
        self.add_defaults(TooltipMixin.defaults)

        # The tooltip text is set in the following variable
        self.tooltip_text = 'left click: change wallpaper\nmiddle click: remove wallpaper\nright click: new wallpaper'
        self.tooltip_fontsize = 32
        self.tooltip_delay = 0.2
        self.tooltip_background = '#D9D7D6'
        self.tooltip_color = '#000A0E'
elParaguayo commented 3 months ago

Thanks. Will test later.

elParaguayo commented 3 months ago

Can you try #348 please?

DeeeeLAN commented 3 months ago

That is working for me.

elParaguayo commented 3 months ago

Thanks. I've merged that fix.