def patch_camera(set_provider=CAM.EXPLICIT): """Choose a predefined camera provider for some platforms.""" CoreCamera = core_camera.Camera set_provider = set_provider or CAM.IMPLICIT.get(PLATFORM) if CAM.ENABLE and set_provider: for provider in core_camera.providers: if set_provider == provider[0]: core_camera.providers = (provider,) _CoreCamera = core_select_lib("camera", core_camera.providers) CoreCamera = _CoreCamera or CoreCamera break class PatchedCoreCamera(CoreCamera): def start(self, *args, **kwargs): ret = super(PatchedCoreCamera, self).start(*args, **kwargs) attrs = map(lambda attr: getattr(self, attr, None), ["_update_ev", "fps"]) if all(attrs) and self.fps > 1.0: self._update_ev.cancel() self._update_ev = Clock.schedule_interval( self._update, 1.0 / self.fps ) return ret core_camera.Camera = PatchedCoreCamera uix_camera.CoreCamera = core_camera.Camera
def Config001009000_ChineseFont(): from kivy.core import core_select_lib from kivy.setupconfig import USE_SDL2 #Load the appropriate provider label_libs = [] if USE_SDL2: label_libs += [('sdl2', 'text_sdl2', 'LabelSDL2')] else: label_libs += [('pygame', 'text_pygame', 'LabelPygame')] label_libs += [('pil', 'text_pil', 'LabelPIL')] Label = core_select_lib('text', label_libs) Label.register('DroidSans', 'DroidSansFallback.ttf', 'DroidSansFallback.ttf', 'DroidSansFallback.ttf', 'DroidSansFallback.ttf')
:func:`request_keyboard` to understand how it works. ''' if self.allow_vkeyboard: key = 'single' if self.single_vkeyboard else target if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != 'single' and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation Window = core_select_lib('window', ( ('egl_rpi', 'window_egl_rpi', 'WindowEglRpi'), ('pygame', 'window_pygame', 'WindowPygame'), ('sdl', 'window_sdl', 'WindowSDL'), ('x11', 'window_x11', 'WindowX11'), ), True)
''' raise NotImplementedError("No font_context support in text provider") # Load the appropriate provider label_libs = [] if USE_PANGOFT2: label_libs += [('pango', 'text_pango', 'LabelPango')] if USE_SDL2: label_libs += [('sdl2', 'text_sdl2', 'LabelSDL2')] else: label_libs += [('pygame', 'text_pygame', 'LabelPygame')] label_libs += [ ('pil', 'text_pil', 'LabelPIL')] Text = Label = core_select_lib('text', label_libs) if 'KIVY_DOC' not in os.environ: if not Label: from kivy.logger import Logger import sys Logger.critical('App: Unable to get a Text provider, abort.') sys.exit(1) # FIXME: Better way to do this if Label.__name__ == 'LabelPango': from kivy.core.text.text_pango import PangoFontContextManager FontContextManager = PangoFontContextManager() else: FontContextManager = FontContextManagerBase()
return self._texture.blit_buffer(self._buffer, colorfmt=self._format) self._buffer = None self.dispatch('on_texture') def on_texture(self): pass def on_load(self): pass # Load the appropriate providers providers = () if platform == 'win': providers += (('videocapture', 'camera_videocapture', 'CameraVideoCapture'), ) elif platform == 'macosx': providers += (('avfoundation', 'camera_avfoundation', 'CameraAVFoundation'), ) elif platform == 'android': providers += (('android', 'camera_android', 'CameraAndroid'), ) else: #providers += (('gi', 'camera_gi', 'CameraGi'), ) providers += (('pygst', 'camera_pygst', 'CameraPyGst'), ) providers += (('opencv', 'camera_opencv', 'CameraOpenCV'), ) Camera = core_select_lib('camera', (providers))
'''Return an uniq id for all font parameters''' return str([self.options[x] for x in ( 'font_size', 'font_name_r', 'bold', 'italic')]) def _get_text_size(self): return self._text_size def _set_text_size(self, x): self._text_size = x text_size = property(_get_text_size, _set_text_size, doc='''Get/set the (width, height) of the contrained rendering box''') usersize = property(_get_text_size, _set_text_size, doc='''(deprecated) Use text_size instead.''') # Load the appropriate provider Label = core_select_lib('text', ( ('pygame', 'text_pygame', 'LabelPygame'), ('pil', 'text_pil', 'LabelPIL'), )) # For the first initalization, register the default font if 'KIVY_DOC' not in os.environ: Label.register('DroidSans', 'data/fonts/DroidSans.ttf', 'data/fonts/DroidSans-Italic.ttf', 'data/fonts/DroidSans-Bold.ttf', 'data/fonts/DroidSans-BoldItalic.ttf')
pass def stop(self): pass def on_symbols(self, instance, value): #if self.show_bounds: # self.update_bounds() pass def update_bounds(self): self.canvas.after.remove_group('bounds') if not self.symbols: return with self.canvas.after: Color(1, 0, 0, group='bounds') for symbol in self.symbols: x, y, w, h = symbol.bounds x = self._camera.right - x - w y = self._camera.top - y - h Line(rectangle=[x, y, w, h], group='bounds') # load QRCodeDetector implementation QRScanner = core_select_lib('qr_scanner', ( ('android', 'scanner_android', 'ScannerAndroid'), ('camera', 'scanner_camera', 'ScannerCamera')), False, 'electrum_gui.kivy') Factory.register('QRScanner', cls=QRScanner)
text_size = property(_get_text_size, _set_text_size, doc='''Get/set the (width, height) of the ' 'contrained rendering box''') usersize = property(_get_text_size, _set_text_size, doc='''(deprecated) Use text_size instead.''') # Load the appropriate provider label_libs = [] if USE_SDL2: label_libs += [('sdl2', 'text_sdl2', 'LabelSDL2')] else: label_libs += [('pygame', 'text_pygame', 'LabelPygame')] label_libs += [ ('pil', 'text_pil', 'LabelPIL')] Text = Label = core_select_lib('text', label_libs) if 'KIVY_DOC' not in os.environ: if not Label: from kivy.logger import Logger import sys Logger.critical('App: Unable to get a Text provider, abort.') sys.exit(1) # For the first initialization, register the default font Label.register('Roboto', 'data/fonts/Roboto-Regular.ttf', 'data/fonts/Roboto-Italic.ttf', 'data/fonts/Roboto-Bold.ttf', 'data/fonts/Roboto-BoldItalic.ttf')
def stop(self): '''Stop the video playing''' self._state = '' def pause(self): '''Pause the video .. versionadded:: 1.4.0 ''' self._state = 'paused' def play(self): '''Play the video''' self._state = 'playing' def load(self): '''Load the video from the current filename''' pass def unload(self): '''Unload the actual video''' self._state = '' # Load the appropriate provider Video = core_select_lib('video', ( ('gstreamer', 'video_gstreamer', 'VideoGStreamer'), ('ffmpeg', 'video_ffmpeg', 'VideoFFMpeg'), ('pyglet', 'video_pyglet', 'VideoPyglet'), ))
system clipboard, a fake one will be used. ''' __all__ = ('ClipboardBase', 'Clipboard') from kivy.core import core_select_lib class ClipboardBase(object): def get(self, mimetype): '''Get the current data in clipboard, using the mimetype if possible ''' return None def put(self, data, mimetype): '''Put data on the clipboard, and attach a mimetype ''' pass def get_types(self): '''Return a list of supported mimetypes ''' return [] # load clipboard implementation Clipboard = core_select_lib('clipboard', (('pygame', 'clipboard_pygame', 'ClipboardPygame'), ('dummy', 'clipboard_dummy', 'ClipboardDummy')), True)
"""Return the content width""" if self.texture is None: return 0 return self.texture.width + 2 * self.options["padding_x"] @property def content_height(self): """Return the content height""" if self.texture is None: return 0 return self.texture.height + 2 * self.options["padding_y"] @property def content_size(self): """Return the content size (width, height)""" if self.texture is None: return (0, 0) return (self.content_width, self.content_height) @property def fontid(self): """Return an uniq id for all font parameters""" return str([self.options[x] for x in ("font_size", "font_name", "bold", "italic")]) # Load the appropriate provider Label = core_select_lib( "text", (("pygame", "text_pygame", "LabelPygame"), ("cairo", "text_cairo", "LabelCairo"), ("pil", "text_pil", "LabelPIL")), )
_clipboards.append( ('xclip', 'clipboard_xclip', 'ClipboardXclip')) _clipboards.append( ('xsel', 'clipboard_xsel', 'ClipboardXsel')) if USE_SDL2: _clipboards.append( ('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': _cutbuffers = [ ('xclip', 'clipboard_xclip', 'ClipboardXclip'), ('xsel', 'clipboard_xsel', 'ClipboardXsel'), ] if Clipboard.__class__.__name__ in (c[2] for c in _cutbuffers): CutBuffer = Clipboard else: CutBuffer = core_select_lib('clipboard', _cutbuffers, True) if CutBuffer: Logger.info('CutBuffer: cut buffer support enabled')
pass def _copy_to_gpu(self): """Copy the the buffer into the texture""" if self._texture is None: Logger.debug("Camera: copy_to_gpu() failed, _texture is None !") return self._texture.blit_buffer(self._buffer, colorfmt=self._format) self._buffer = None self.dispatch("on_texture") def on_texture(self): pass def on_load(self): pass # Load the appropriate providers providers = () if sys.platform == "win32": providers += (("videocapture", "camera_videocapture", "CameraVideoCapture"),) if sys.platform != "darwin": providers += (("gstreamer", "camera_gstreamer", "CameraGStreamer"),) providers += (("opencv", "camera_opencv", "CameraOpenCV"),) Camera = core_select_lib("camera", (providers))
('winctypes', 'clipboard_winctypes', 'ClipboardWindows')) elif platform == 'linux': _clipboards.append( ('dbusklipper', 'clipboard_dbusklipper', 'ClipboardDbusKlipper')) _clipboards.append(('gtk3', 'clipboard_gtk3', 'ClipboardGtk3')) _clipboards.append(('xclip', 'clipboard_xclip', 'ClipboardXclip')) _clipboards.append(('xsel', 'clipboard_xsel', 'ClipboardXsel')) if USE_SDL2: _clipboards.append(('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append(('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append(('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': _cutbuffers = [ ('xclip', 'clipboard_xclip', 'ClipboardXclip'), ('xsel', 'clipboard_xsel', 'ClipboardXsel'), ] if Clipboard.__class__.__name__ in (c[2] for c in _cutbuffers): CutBuffer = Clipboard else: CutBuffer = core_select_lib('clipboard', _cutbuffers, True) if CutBuffer: Logger.info('CutBuffer: cut buffer support enabled')
_set_text_size, doc="""Get/set the (width, height) of the ' 'contrained rendering box""", ) usersize = property(_get_text_size, _set_text_size, doc="""(deprecated) Use text_size instead.""") # Load the appropriate provider label_libs = [] if USE_SDL2: label_libs += [("sdl2", "text_sdl2", "LabelSDL2")] else: label_libs += [("pygame", "text_pygame", "LabelPygame")] label_libs += [("pil", "text_pil", "LabelPIL")] Text = Label = core_select_lib("text", label_libs) if "KIVY_DOC" not in os.environ: if not Label: from kivy.logger import Logger import sys Logger.critical("App: Unable to get a Text provider, abort.") sys.exit(1) # For the first initalization, register the default font Label.register( "Roboto", "data/fonts/Roboto-Regular.ttf", "data/fonts/Roboto-Italic.ttf", "data/fonts/Roboto-Bold.ttf",
return self._text_size def _set_text_size(self, x): self._text_size = x text_size = property(_get_text_size, _set_text_size, doc='''Get/set the (width, height) of the ' 'contrained rendering box''') usersize = property(_get_text_size, _set_text_size, doc='''(deprecated) Use text_size instead.''') # Load the appropriate provider Label = core_select_lib('text', ( ('pygame', 'text_pygame', 'LabelPygame'), ('sdlttf', 'text_sdlttf', 'LabelSDLttf'), ('pil', 'text_pil', 'LabelPIL'), )) if 'KIVY_DOC' not in os.environ: if not Label: from kivy.logger import Logger import sys Logger.critical('App: Unable to get a Text provider, abort.') sys.exit(1) # For the first initalization, register the default font Label.register('DroidSans', 'data/fonts/DroidSans.ttf', 'data/fonts/DroidSans-Italic.ttf', 'data/fonts/DroidSans-Bold.ttf',
if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != 'single' and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation window_impl = [] if platform == 'linux': window_impl += [('egl_rpi', 'window_egl_rpi', 'WindowEglRpi')] if USE_SDL2: window_impl += [('sdl2', 'window_sdl2', 'WindowSDL')] else: window_impl += [('pygame', 'window_pygame', 'WindowPygame')] if platform == 'linux': window_impl += [('x11', 'window_x11', 'WindowX11')] Window = core_select_lib('window', window_impl, True)
''' self._state = 'paused' def play(self): '''Play the video''' self._state = 'playing' def load(self): '''Load the video from the current filename''' pass def unload(self): '''Unload the actual video''' self._state = '' # Load the appropriate provider video_providers = [] try: from kivy.lib.gstplayer import GstPlayer # NOQA video_providers += [('gstplayer', 'video_gstplayer', 'VideoGstplayer')] except ImportError: pass video_providers += [ ('ffmpeg', 'video_ffmpeg', 'VideoFFMpeg'), ('ffpyplayer', 'video_ffpyplayer', 'VideoFFPy'), ('null', 'video_null', 'VideoNull')] Video = core_select_lib('video', video_providers)
('winctypes', 'clipboard_winctypes', 'ClipboardWindows')) elif platform == 'linux': _clipboards.append(('xclip', 'clipboard_xclip', 'ClipboardXclip')) _clipboards.append(('xsel', 'clipboard_xsel', 'ClipboardXsel')) _clipboards.append( ('dbusklipper', 'clipboard_dbusklipper', 'ClipboardDbusKlipper')) _clipboards.append(('gtk3', 'clipboard_gtk3', 'ClipboardGtk3')) if USE_SDL2: _clipboards.append(('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append(('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append(('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': _cutbuffers = [ ('xclip', 'clipboard_xclip', 'ClipboardXclip'), ('xsel', 'clipboard_xsel', 'ClipboardXsel'), ] if Clipboard.__class__.__name__ in (c[2] for c in _cutbuffers): CutBuffer = Clipboard else: CutBuffer = core_select_lib('cutbuffer', _cutbuffers, True, basemodule='clipboard')
def stop(self): '''Release the camera''' self.stopped = True Clock.unschedule(self._update) def _update(self, dt): '''Update the camera (internal)''' pass def _copy_to_gpu(self): '''Copy the the buffer into the texture''' if self._texture is None: Logger.debug('Camera: copy_to_gpu() failed, _texture is None !') return self._texture.blit_buffer(self._buffer, fmt=self._format) self._buffer = None self.dispatch('on_frame') def on_frame(self): pass def on_load(self): pass # Load the appropriate provider Camera = core_select_lib('camera', ( ('gstreamer', 'camera_gstreamer', 'CameraGStreamer'), ('opencv', 'camera_opencv', 'CameraOpenCV'), ('videocapture', 'camera_videocapture', 'CameraVideoCapture'), ))
_clipboards.append( ('gtk3', 'clipboard_gtk3', 'ClipboardGtk3')) _clipboards.append( ('xsel', 'clipboard_xsel', 'ClipboardXsel')) if USE_SDL2: if platform != 'linux': _clipboards.append( ('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': try: from kivy.core.clipboard.clipboard_xsel import ClipboardXsel except Exception: pass else: if isinstance(Clipboard, ClipboardXsel): CutBuffer = Clipboard else: CutBuffer = ClipboardXsel() Logger.info('CutBuffer: cut buffer support enabled')
''' return None def put(self, data, mimetype): '''Put data on the clipboard, and attach a mimetype ''' pass def get_types(self): '''Return a list of supported mimetypes ''' return [] # load clipboard implementation _clipboards = [] _platform = platform if _platform == 'android': _clipboards.append( ('android', 'clipboard_android', 'ClipboardAndroid')) elif _platform in ('macosx', 'linux', 'win'): _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) del _clipboards del _platform
]) def _get_text_size(self): return self._text_size def _set_text_size(self, x): self._text_size = x text_size = property( _get_text_size, _set_text_size, doc='''Get/set the (width, height) of the contrained rendering box''') usersize = property(_get_text_size, _set_text_size, doc='''(deprecated) Use text_size instead.''') # Load the appropriate provider Label = core_select_lib('text', ( ('pygame', 'text_pygame', 'LabelPygame'), ('pil', 'text_pil', 'LabelPIL'), )) # For the first initalization, register the default font if 'KIVY_DOC' not in os.environ: Label.register('DroidSans', 'data/fonts/DroidSans.ttf', 'data/fonts/DroidSans-Italic.ttf', 'data/fonts/DroidSans-Bold.ttf', 'data/fonts/DroidSans-BoldItalic.ttf')
if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != "single" and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation window_impl = [] if platform == "linux": window_impl += [("egl_rpi", "window_egl_rpi", "WindowEglRpi")] if USE_SDL2: window_impl += [("sdl2", "window_sdl2", "WindowSDL")] else: window_impl += [("pygame", "window_pygame", "WindowPygame")] if platform == "linux": window_impl += [("x11", "window_x11", "WindowX11")] Window = core_select_lib("window", window_impl, True)
def release_keyboard(self, target=None): '''.. versionadded:: 1.0.4 Internal method for widget, to release the real-keyboard. Check :func:`request_keyboard` to understand how it works. ''' if self.allow_vkeyboard: key = 'single' if self.single_vkeyboard else target if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != 'single' and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation Window = core_select_lib('window', (('pygame', 'window_pygame', 'WindowPygame'), ), True)
''' Initialize the adapter. ''' pass def nfc_disable(self): ''' Disable scanning ''' pass def nfc_enable(self): ''' Enable Scanning ''' pass def nfc_enable_exchange(self, data): ''' Enable P2P Ndef exchange ''' pass def nfc_disable_exchange(self): ''' Disable/Stop P2P Ndef exchange ''' pass # load NFCScanner implementation NFCScanner = core_select_lib('nfc_manager', ( # keep the dummy implementation as the last one to make it the fallback provider.NFCScanner = core_select_lib('nfc_scanner', ( ('android', 'scanner_android', 'ScannerAndroid'), ('dummy', 'scanner_dummy', 'ScannerDummy')), True, 'electrum.gui.kivy')
return False. :Parameters: `word`: str The word to check. ''' raise NotImplementedError('check() not implemented by abstract ' + 'spelling base class!') def suggest(self, fragment): ''' For a given `fragment` (i.e. part of a word or a word by itself), provide corrections (`fragment` may be misspelled) or completions as a list of strings. :Parameters: `fragment`: str The word fragment to get suggestions/corrections for. E.g. 'foo' might become 'of', 'food' or 'foot'. ''' raise NotImplementedError('suggest() not implemented by abstract ' + 'spelling base class!') _libs = (('enchant', 'spelling_enchant', 'SpellingEnchant'), ) if sys.platform == 'darwin': _libs += (('osxappkit', 'spelling_osxappkit', 'SpellingOSXAppKit'), ) Spelling = core_select_lib('spelling', _libs)
if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != "single" and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation Window = core_select_lib( "window", ( ("egl_rpi", "window_egl_rpi", "WindowEglRpi"), ("pygame", "window_pygame", "WindowPygame"), ("sdl", "window_sdl", "WindowSDL"), ("x11", "window_x11", "WindowX11"), ), True, )
_clipboards.append( ('xclip', 'clipboard_xclip', 'ClipboardXclip')) _clipboards.append( ('xsel', 'clipboard_xsel', 'ClipboardXsel')) if USE_SDL2: _clipboards.append( ('sdl2', 'clipboard_sdl2', 'ClipboardSDL2')) else: _clipboards.append( ('pygame', 'clipboard_pygame', 'ClipboardPygame')) _clipboards.append( ('dummy', 'clipboard_dummy', 'ClipboardDummy')) Clipboard = core_select_lib('clipboard', _clipboards, True) CutBuffer = None if platform == 'linux': _cutbuffers = [ ('xclip', 'clipboard_xclip', 'ClipboardXclip'), ('xsel', 'clipboard_xsel', 'ClipboardXsel'), ] if Clipboard.__class__.__name__ in (c[2] for c in _cutbuffers): CutBuffer = Clipboard else: CutBuffer = core_select_lib('cutbuffer', _cutbuffers, True, basemodule='clipboard') if CutBuffer:
self._text_size = x text_size = property(_get_text_size, _set_text_size, doc='''Get/set the (width, height) of the ' 'contrained rendering box''') usersize = property(_get_text_size, _set_text_size, doc='''(deprecated) Use text_size instead.''') # Load the appropriate provider Label = core_select_lib('text', ( ('pygame', 'text_pygame', 'LabelPygame'), ('sdl2', 'text_sdl2', 'LabelSDL2'), ('sdlttf', 'text_sdlttf', 'LabelSDLttf'), ('pil', 'text_pil', 'LabelPIL'), )) if 'KIVY_DOC' not in os.environ: if not Label: from kivy.logger import Logger import sys Logger.critical('App: Unable to get a Text provider, abort.') sys.exit(1) # For the first initalization, register the default font Label.register('DroidSans', 'data/fonts/DroidSans.ttf', 'data/fonts/DroidSans-Italic.ttf', 'data/fonts/DroidSans-Bold.ttf', 'data/fonts/DroidSans-BoldItalic.ttf')
''' __all__ = ('ClipboardBase', 'Clipboard') from kivy.core import core_select_lib class ClipboardBase(object): def get(self, mimetype): '''Get the current data in clipboard, using the mimetype if possible ''' return None def put(self, data, mimetype): '''Put data on the clipboard, and attach a mimetype ''' pass def get_types(self): '''Return a list of supported mimetypes ''' return [] # load clipboard implementation Clipboard = core_select_lib('clipboard', ( ('pygame', 'clipboard_pygame', 'ClipboardPygame'), ('dummy', 'clipboard_dummy', 'ClipboardDummy')), True)
return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != 'single' and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation window_impl = [] if platform == 'linux': window_impl += [('egl_rpi', 'window_egl_rpi', 'WindowEglRpi')] if USE_SDL2: window_impl += [('sdl2', 'window_sdl2', 'WindowSDL')] else: window_impl += [ ('pygame', 'window_pygame', 'WindowPygame'), ('sdl', 'window_sdl', 'WindowSDL')] if platform == 'linux': window_impl += [('x11', 'window_x11', 'WindowX11')] Window = core_select_lib('window', window_impl, True)
The word to check. If the word is a valid word in the currently active language, True is returned. If the word shouldn't be checked, return None (e.g. for ''). ''' raise NotImplementedError('check() not implemented by abstract ' + 'spelling base class!') def suggest(self, fragment): ''' For a given `fragment` (i.e., part of a word or a word by itself), provide corrections (`fragment` may be misspelled) or completions as a list of strings. :Parameters: `fragment` : str The word fragment to get suggestions/corrections for. E.g.: 'foo' might become 'of', 'food' or 'foot'. ''' raise NotImplementedError('suggest() not implemented by abstract ' + 'spelling base class!') _libs = (('enchant', 'spelling_enchant', 'SpellingEnchant'), ) if sys.platform == 'darwin': _libs += (('osxappkit', 'spelling_osxappkit', 'SpellingOSXAppKit'), ) Spelling = core_select_lib('spelling', _libs)
''' Disable scanning ''' pass def nfc_enable(self): ''' Enable Scanning ''' pass def nfc_enable_exchange(self, data): ''' Enable P2P Ndef exchange ''' pass def nfc_disable_exchange(self): ''' Disable/Stop P2P Ndef exchange ''' pass # load NFCScanner implementation NFCScanner = core_select_lib( 'nfc_manager', ( # keep the dummy implementation as the last one to make it the fallback provider.NFCScanner = core_select_lib('nfc_scanner', ( ('android', 'scanner_android', 'ScannerAndroid'), ('dummy', 'scanner_dummy', 'ScannerDummy')), True, 'electrum_xzc.gui.kivy')
""" __all__ = ("ClipboardBase", "Clipboard") from kivy.core import core_select_lib class ClipboardBase(object): def get(self, mimetype): """Get the current data in clipboard, using the mimetype if possible """ return None def put(self, data, mimetype): """Put data on the clipboard, and attach a mimetype """ pass def get_types(self): """Return a list of supported mimetypes """ return [] # load clipboard implementation Clipboard = core_select_lib( "clipboard", (("pygame", "clipboard_pygame", "ClipboardPygame"), ("dummy", "clipboard_dummy", "ClipboardDummy")), True, )
self._state = 'playing' def load(self): '''Load the video from the current filename''' pass def unload(self): '''Unload the actual video''' self._state = '' # Load the appropriate provider video_providers = [] try: from kivy.lib.gstplayer import GstPlayer video_providers += [('gstplayer', 'video_gstplayer', 'VideoGstplayer')] except ImportError: #video_providers += [('gi', 'video_gi', 'VideoGi')] if PY2: # if peoples do not have gi, fallback on pygst, only for python2 video_providers += [ ('pygst', 'video_pygst', 'VideoPyGst')] video_providers += [ ('ffmpeg', 'video_ffmpeg', 'VideoFFMpeg'), ('pyglet', 'video_pyglet', 'VideoPyglet'), ('null', 'video_null', 'VideoNull')] Video = core_select_lib('video', video_providers)
Internal method for widget, to release the real-keyboard. Check :func:`request_keyboard` to understand how it works. ''' if self.allow_vkeyboard: key = 'single' if self.single_vkeyboard else target if key not in self._keyboards: return keyboard = self._keyboards[key] callback = keyboard.callback if callback: keyboard.callback = None callback() keyboard.target = None self.remove_widget(keyboard.widget) if key != 'single' and key in self._keyboards: del self._keyboards[key] elif self._system_keyboard.callback: # this way will prevent possible recursion. callback = self._system_keyboard.callback self._system_keyboard.callback = None callback() return True #: Instance of a :class:`WindowBase` implementation Window = core_select_lib('window', ( ('pygame', 'window_pygame', 'WindowPygame'), ), True)
def stop(self): pass def on_symbols(self, instance, value): #if self.show_bounds: # self.update_bounds() pass def update_bounds(self): self.canvas.after.remove_group('bounds') if not self.symbols: return with self.canvas.after: Color(1, 0, 0, group='bounds') for symbol in self.symbols: x, y, w, h = symbol.bounds x = self._camera.right - x - w y = self._camera.top - y - h Line(rectangle=[x, y, w, h], group='bounds') # load QRCodeDetector implementation QRScanner = core_select_lib('qr_scanner', (('android', 'scanner_android', 'ScannerAndroid'), ('camera', 'scanner_camera', 'ScannerCamera')), False, 'electrum_gui.kivy') Factory.register('QRScanner', cls=QRScanner)
if self._texture is None: Logger.debug('Camera: copy_to_gpu() failed, _texture is None !') return self._texture.blit_buffer(self._buffer, colorfmt=self._format) self._buffer = None self.dispatch('on_texture') def on_texture(self): pass def on_load(self): pass # Load the appropriate providers providers = () if sys.platform == 'win32': providers += (('videocapture', 'camera_videocapture', 'CameraVideoCapture'), ) elif sys.platform == 'darwin': providers += (('avfoundation', 'camera_avfoundation', 'CameraAVFoundation'), ) else: #providers += (('gi', 'camera_gi', 'CameraGi'), ) providers += (('pygst', 'camera_pygst', 'CameraPyGst'), ) providers += (('opencv', 'camera_opencv', 'CameraOpenCV'), ) Camera = core_select_lib('camera', (providers))
'''Release the camera''' self.stopped = True Clock.unschedule(self._update) def _update(self, dt): '''Update the camera (internal)''' pass def _copy_to_gpu(self): '''Copy the the buffer into the texture''' if self._texture is None: Logger.debug('Camera: copy_to_gpu() failed, _texture is None !') return self._texture.blit_buffer(self._buffer, colorfmt=self._format) self._buffer = None self.dispatch('on_frame') def on_frame(self): pass def on_load(self): pass # Load the appropriate provider Camera = core_select_lib('camera', ( ('gstreamer', 'camera_gstreamer', 'CameraGStreamer'), ('opencv', 'camera_opencv', 'CameraOpenCV'), ('videocapture', 'camera_videocapture', 'CameraVideoCapture'), ))