__all__ = ('ClipboardSDL2', ) from kivy.utils import platform from kivy.core.clipboard import ClipboardBase if platform not in ('win', 'linux', 'macosx', 'android', 'ios'): raise SystemError('unsupported platform for sdl2 clipboard') try: from kivy.core.clipboard._clipboard_sdl2 import (_get_text, _has_text, _set_text) except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error('Clipboard', 'sdl2', 'kivy.core.clipboard._clipboard_sdl2') raise class ClipboardSDL2(ClipboardBase): def get(self, mimetype): return _get_text() if _has_text() else '' def _ensure_clipboard(self): super(ClipboardSDL2, self)._ensure_clipboard() self._encoding = 'utf8' def put(self, data=b'', mimetype='text/plain'): _set_text(data) def get_types(self):
__all__ = ('WindowSDL', ) from os.path import join import sys from kivy import kivy_data_dir from kivy.logger import Logger from kivy.base import EventLoop from kivy.clock import Clock from kivy.config import Config from kivy.core.window import WindowBase try: from kivy.core.window._window_sdl2 import _WindowSDL2Storage except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error('window', 'sdl2', 'kivy.core.window._window_sdl2') raise from kivy.input.provider import MotionEventProvider from kivy.input.motionevent import MotionEvent from kivy.resources import resource_find from kivy.utils import platform, deprecated from kivy.compat import unichr from collections import deque # SDL_keycode.h, https://wiki.libsdl.org/SDL_Keymod KMOD_NONE = 0x0000 KMOD_LSHIFT = 0x0001 KMOD_RSHIFT = 0x0002 KMOD_LCTRL = 0x0040 KMOD_RCTRL = 0x0080 KMOD_LALT = 0x0100
''' Video Gstplayer =============== .. versionadded:: 1.8.0 Implementation of a VideoBase with Kivy :class:`~kivy.lib.gstplayer.GstPlayer` This player is the preferred player, using Gstreamer 1.0, working on both Python 2 and 3. ''' try: from kivy.lib.gstplayer import GstPlayer, get_gst_version except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'VideoGstplayer', 'gst', 'kivy.lib.gstplayer._gstplayer') raise from kivy.graphics.texture import Texture from kivy.core.video import VideoBase from kivy.logger import Logger from kivy.clock import Clock from kivy.compat import PY2 from threading import Lock from functools import partial from os.path import realpath from weakref import ref if PY2: from urllib import pathname2url else: from urllib.request import pathname2url
Based on SDL2 + SDL2_ttf ''' __all__ = ('LabelSDL2', ) from kivy.compat import PY2 from kivy.core.text import LabelBase try: from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents, _get_fontdescent, _get_fontascent) except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error('text', 'sdl2', 'kivy.core.text._text_sdl2') raise class LabelSDL2(LabelBase): def _get_font_id(self): if PY2: try: return '|'.join([ unicode(self.options[x]) for x in ('font_size', 'font_name_r', 'bold', 'italic', 'underline', 'strikethrough') ]) except UnicodeDecodeError: pass return '|'.join([
''' Video Gstplayer =============== .. versionadded:: 1.8.0 Implementation of a VideoBase with Kivy :class:`~kivy.lib.gstplayer.GstPlayer` This player is the preferred player, using Gstreamer 1.0, working on both Python 2 and 3. ''' try: from kivy.lib.gstplayer import GstPlayer, get_gst_version except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'VideoGstplayer', 'gst', 'kivy.lib.gstplayer._gstplayer') raise from kivy.graphics.texture import Texture from kivy.core.video import VideoBase from kivy.logger import Logger from kivy.clock import Clock from kivy.compat import PY2 from threading import Lock from functools import partial from os.path import realpath from weakref import ref if PY2: from urllib import pathname2url else: from urllib.request import pathname2url
SDL2 text provider ================== Based on SDL2 + SDL2_ttf ''' __all__ = ('LabelSDL2', ) from kivy.compat import PY2 from kivy.core.text import LabelBase try: from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents, _get_fontdescent, _get_fontascent) except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'text', 'sdl2', 'kivy.core.text._text_sdl2') raise class LabelSDL2(LabelBase): def _get_font_id(self): if PY2: try: return '|'.join([unicode(self.options[x]) for x in ('font_size', 'font_name_r', 'bold', 'italic', 'underline', 'strikethrough')]) except UnicodeDecodeError: pass return '|'.join([str(self.options[x]) for x in ('font_size', 'font_name_r', 'bold',
''' SDL2 image loader ================= ''' __all__ = ('ImageLoaderSDL2', ) from kivy.logger import Logger from kivy.core.image import ImageLoaderBase, ImageData, ImageLoader try: from kivy.core.image import _img_sdl2 except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'image', 'sdl2', 'kivy.core.image._img_sdl2') raise class ImageLoaderSDL2(ImageLoaderBase): '''Image loader based on SDL2_image''' def _ensure_ext(self): _img_sdl2.init() @staticmethod def extensions(): '''Return accepted extensions for this loader''' return ('bmp', 'jpg', 'jpeg', 'jpe', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff', 'webp', 'xcf', 'xpm', 'xv') @staticmethod
__all__ = ('WindowSDL2', ) from os.path import join import sys from kivy import kivy_data_dir from kivy.logger import Logger from kivy.base import EventLoop, ExceptionManager, stopTouchApp from kivy.clock import Clock from kivy.config import Config from kivy.core.window import WindowBase try: from kivy.core.window._window_sdl2 import _WindowSDL2Storage except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'window', 'sdl2', 'kivy.core.window._window_sdl2') raise from kivy.input.provider import MotionEventProvider from kivy.input.motionevent import MotionEvent from kivy.resources import resource_find from kivy.utils import platform, deprecated from kivy.compat import unichr from collections import deque KMOD_LCTRL = 64 KMOD_RCTRL = 128 KMOD_RSHIFT = 2 KMOD_LSHIFT = 1 KMOD_RALT = 512 KMOD_LALT = 256 KMOD_LMETA = 1024
''' SDL2 image loader ================= ''' __all__ = ('ImageLoaderSDL2', ) from kivy.logger import Logger from kivy.core.image import ImageLoaderBase, ImageData, ImageLoader try: from kivy.core.image import _img_sdl2 except ImportError: from kivy.core import handle_win_lib_import_error handle_win_lib_import_error( 'image', 'sdl2', 'kivy.core.image._img_sdl2') raise class ImageLoaderSDL2(ImageLoaderBase): '''Image loader based on SDL2_image''' def _ensure_ext(self): _img_sdl2.init() @staticmethod def extensions(): '''Return accepted extensions for this loader''' return ('bmp', 'jpg', 'jpeg', 'jpe', 'lbm', 'pcx', 'png', 'pnm', 'tga', 'tiff', 'webp', 'xcf', 'xpm', 'xv') @staticmethod