File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,21 @@ def _paste(self):
119
119
if _platform == 'android' :
120
120
_clipboards .append (
121
121
('android' , 'clipboard_android' , 'ClipboardAndroid' ))
122
+ _clipboards .append (
123
+ ('sdl2' , 'clipboard_sdl2' , 'ClipboardSDL2' ))
124
+ elif _platform == 'ios' :
125
+ _clipboards .append (
126
+ ('sdl2' , 'clipboard_sdl2' , 'ClipboardSDL2' ))
122
127
elif _platform in ('macosx' , 'linux' , 'win' ):
128
+ if _platform == 'macosx' :
129
+ _clipboards .append (
130
+ ('nspaste' , 'clipboard_nspaste' , 'ClipboardNSPaste' ))
131
+ elif _platform == 'win' :
132
+ _clipboards .append (
133
+ ('winctypes' , 'clipboard_winctypes' , 'ClipboardWindows' ))
134
+ elif _platform == 'linux' :
135
+ _clipboards .append (('dbusklipper' , 'clipboard_dbusklipper' , 'Clipboard_DbusKlipper' ))
136
+
123
137
_clipboards .append (
124
138
('pygame' , 'clipboard_pygame' , 'ClipboardPygame' ))
125
139
_clipboards .append (
Original file line number Diff line number Diff line change
1
+ '''
2
+ Clipboard OsX: implementation of clipboard using Appkit
3
+ '''
4
+
5
+ __all__ = ('ClipboardNSPaste' , )
6
+
7
+ from kivy .core .clipboard import ClipboardBase
8
+ from kivy .utils import platform
9
+
10
+ if platform != 'macosx' :
11
+ raise SystemError ('Unsupported platform for appkit clipboard.' )
12
+ try :
13
+ from pyobjus import autoclass
14
+ from pyobjus .dylib_manager import load_framework , INCLUDE
15
+ load_framework (INCLUDE .AppKit )
16
+ except ImportError :
17
+ raise SystemError ('Pyobjus not installed. Please run the following'
18
+ ' command to install it. `pip install --user pyobjus`' )
19
+
20
+ NSPasteboard = autoclass ('NSPasteboard' )
21
+ NSString = autoclass ('NSString' )
22
+
23
+
24
+ class ClipboardNSPaste (ClipboardBase ):
25
+
26
+ def __init__ (self ):
27
+ super (ClipboardNSPaste , self ).__init__ ()
28
+ self ._clipboard = NSPasteboard .generalPasteboard ()
29
+
30
+ def get (self , mimetype = 'text/plain' ):
31
+ pb = self ._clipboard
32
+ return pb .stringForType_ ('public.utf8-plain-text' ).UTF8String ()
33
+
34
+ def put (self , data , mimetype = 'text/plain' ):
35
+ pb = self ._clipboard
36
+ pb .clearContents ()
37
+ pb .writeObjects_ ([data ])
38
+
39
+ def get_types (self ):
40
+ return list ('text/plain' ,)
You can’t perform that action at this time.
0 commit comments