ppizarror / pygame-menu

A menu for pygame. Simple, and easy to use
https://pygame-menu.readthedocs.io/
Other
555 stars 141 forks source link

TextInput widget's copy-paste fails silently #485

Closed maqp closed 2 weeks ago

maqp commented 2 months ago

Problem:

On Ubuntu 24.04 LTS that defaults to Wayland, trying to paste to TextInput widget fails silently on line 1293.

The reason for this was that as per Pyperclip, one of the packets in xclip, xsel, or wl-clipboard was missing. Of these at least wl-clipboard works, I didn't test others.

Solution:

Perhaps the library could try to detect the platform and either print a warning, or raise an exception when this happens. E.g.

# Paste text in cursor
try:
    text = paste()
except PyperclipException:
    import os
    if os.getenv("XDG_SESSION_TYPE") == 'wayland':
        raise PyperclipException("Pasting from clipboard failed. Please install package 'wl-clipboard'")
    return False
ppizarror commented 2 weeks ago

Hi @maqp. I added two warnings if copy/paste fails.

https://github.com/ppizarror/pygame-menu/blob/0f996e2e6c783aa035b6728819e36c74ef596fbd/pygame_menu/widgets/widget/textinput.py#L64-L79

Let me know if that addresses the enh, so you can close this issue. Thanks!