mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 16:27:13 +03:00
[1471] Add PIL to Improve Clipboard
This commit is contained in:
parent
ccda74c8f1
commit
572f724a71
@ -802,4 +802,7 @@
|
|||||||
"Ships" = "Ships";
|
"Ships" = "Ships";
|
||||||
|
|
||||||
/* update.py: Update Available Text; In files: update.py:229; */
|
/* update.py: Update Available Text; In files: update.py:229; */
|
||||||
"{NEWVER} is available" = "{NEWVER} is available";
|
"{NEWVER} is available" = "{NEWVER} is available";
|
||||||
|
|
||||||
|
/* myNotebook.py: Can't Paste Images or Files in Text; */
|
||||||
|
"Cannot paste non-text content." = "Cannot paste non-text content.";
|
||||||
|
1
build.py
1
build.py
@ -133,7 +133,6 @@ def build() -> None:
|
|||||||
"distutils",
|
"distutils",
|
||||||
"_markerlib",
|
"_markerlib",
|
||||||
"optparse",
|
"optparse",
|
||||||
"PIL",
|
|
||||||
"simplejson",
|
"simplejson",
|
||||||
"unittest",
|
"unittest",
|
||||||
"doctest",
|
"doctest",
|
||||||
|
@ -14,7 +14,12 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk, messagebox
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
from PIL import ImageGrab
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
def _(x: str) -> str: return x
|
||||||
|
|
||||||
# Can't do this with styles on OSX - http://www.tkdocs.com/tutorial/styles.html#whydifficult
|
# Can't do this with styles on OSX - http://www.tkdocs.com/tutorial/styles.html#whydifficult
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
@ -126,13 +131,22 @@ class EntryMenu(ttk.Entry):
|
|||||||
|
|
||||||
def paste(self) -> None:
|
def paste(self) -> None:
|
||||||
"""Paste the selected Entry text."""
|
"""Paste the selected Entry text."""
|
||||||
if self.selection_present():
|
|
||||||
self.delete(tk.SEL_FIRST, tk.SEL_LAST)
|
|
||||||
try:
|
try:
|
||||||
|
# Attempt to grab an image from the clipboard (apprently also works for files)
|
||||||
|
img = ImageGrab.grabclipboard()
|
||||||
|
if img:
|
||||||
|
# Hijack existing translation, yes it doesn't exactly match here.
|
||||||
|
# LANG: Generic error prefix - following text is from Frontier auth service;
|
||||||
|
messagebox.showwarning(_('Error'),
|
||||||
|
_('Cannot paste non-text content.')) # LANG: Can't Paste Images or Files in Text
|
||||||
|
return
|
||||||
text = self.clipboard_get()
|
text = self.clipboard_get()
|
||||||
|
if self.selection_present() and text:
|
||||||
|
self.delete(tk.SEL_FIRST, tk.SEL_LAST)
|
||||||
self.insert(tk.INSERT, text)
|
self.insert(tk.INSERT, text)
|
||||||
except tk.TclError:
|
except tk.TclError:
|
||||||
pass # No text in clipboard or clipboard is not text
|
# No text in clipboard or clipboard is not text
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Entry(sys.platform == 'darwin' and tk.Entry or EntryMenu or ttk.Entry): # type: ignore
|
class Entry(sys.platform == 'darwin' and tk.Entry or EntryMenu or ttk.Entry): # type: ignore
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
certifi==2023.11.17
|
certifi==2023.11.17
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
|
pillow==10.2.0
|
||||||
# requests depends on this now ?
|
# requests depends on this now ?
|
||||||
charset-normalizer==2.1.1
|
charset-normalizer==2.1.1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user