bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.25k stars 56 forks source link

[BUG] Inline widget: Mouse report event 'hover' is not supported #135

Closed jdlangs closed 7 months ago

jdlangs commented 1 year ago

Describe the bug Inline widget doesn't work because my setup reports the "hover" mouse event isn't supported

To Reproduce Run a simple inline example:

import pytermgui as ptg
ptg.inline(ptg.Label("Hello World"))

Behavior Exception thrown with this traceback:

/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, imp, stat
Traceback (most recent call last):─────┘
  File "/home/user/.local/lib/python3.8/site-packages/pytermgui/context_managers.py", line 142, in mouse_handler
    report_mouse(event, method=method)
  File "/home/user/.local/lib/python3.8/site-packages/pytermgui/ansi_interface.py", line 522, in report_mouse
    raise NotImplementedError(f"Mouse report event {event!r} is not supported!")
NotImplementedError: Mouse report event 'hover' is not supported!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ptg_inline.py", line 2, in <module>
    ptg.inline(ptg.Container("Hello World"))
  File "/home/user/.local/lib/python3.8/site-packages/pytermgui/widgets/inline.py", line 90, in inline
    with mouse_handler(["press_hold", "hover"], "decimal_xterm") as translate:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/home/user/.local/lib/python3.8/site-packages/pytermgui/context_managers.py", line 148, in mouse_handler
    report_mouse(event, method=method, stop=True)
  File "/home/user/.local/lib/python3.8/site-packages/pytermgui/ansi_interface.py", line 522, in report_mouse
    raise NotImplementedError(f"Mouse report event {event!r} is not supported!")
NotImplementedError: Mouse report event 'hover' is not supported!```

Screenshots

System information

❯ ptg --version                                                                                                                                                                                                  ─╯
PyTermGUI version 7.7.0

System details:
    Python version: 3.8.10
    $TERM:          xterm-256color
    $COLORTERM:     truecolor
    Color support:  ColorSystem.TRUE
    OS Platform:    Linux-5.15.0-79-generic-x86_64-with-glibc2.29

I'm running Ubuntu 20.04 and this error happened with both Terminator and Gnome Terminal emulators.

Possible cause The error originates with this line

Possible solution I'm not sure if there's something wrong with my system configuration or if the inline widget should be more robust to not having the hover functionality.

Thanks in advance and for your work in creating this! I just started trying it out yesterday and it's been a great experience.

bczsalba commented 7 months ago

Coming back around to tie up some loose ends here, this was a really stupid issue I managed to overlook. Fixed now, so it should be in the next release.