Catch any errors getting the clipboard data

I haven't run into this, but since we've got a nice localized string for it...
This commit is contained in:
Isaiah Odhner 2023-05-01 16:56:43 -04:00
parent a20f2c05d7
commit d8d0871729

View File

@ -2131,8 +2131,12 @@ class PaintApp(App[None]):
def action_paste(self) -> None:
"""Paste the clipboard as a selection."""
import pyperclip
text: str = pyperclip.paste()
try:
import pyperclip
text: str = pyperclip.paste()
except Exception as e:
self.warning_message_box(_("Paint"), _("Error getting the Clipboard Data!") + "\n\n" + repr(e), "ok")
return
if not text:
return
if self.image.selection and self.image.selection.textbox_mode: