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'), ))
@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'), ))
'''Start the camera acquire''' self.stopped = False def stop(self): '''Release the camera''' self.stopped = True def _copy_to_gpu(self): '''Copy the the buffer into the texture''' if self._texture is None: pymt_logger.debug('Camera: copy_to_gpu() failed, _texture is None !') return self._texture.blit_buffer(self._buffer, format=self._format) self._buffer = None def draw(self): '''Draw the current image camera''' if self._texture: set_color(*self.color) drawTexturedRectangle(self._texture, pos=self.pos, size=self.size) else: drawRectangle(pos=self.pos, size=self.size) drawLabel('No Camera :(', pos=(self.width/2, self.height/2)) # Load the appropriate provider Camera = core_select_lib('camera', ( ('gstreamer', 'camera_gstreamer', 'CameraGStreamer'), ('opencv', 'camera_opencv', 'CameraOpenCV'), ('videocapture', 'camera_videocapture', 'CameraVideoCapture'), ))
''' Clipboard: get/put data from system clipboard ''' __all__ = ('ClipboardBase', 'Clipboard') from pymt.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') ))()
:Parameters: `word` : str 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() method 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() method 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)
:Parameters: `word` : str The word to check. If the word is a valid word in the currently active language, True is returned. ''' raise NotImplementedError('check() method 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() method not implemented by abstract ' + \ 'spelling base class!') Spelling = core_select_lib('spelling', ( ('enchant', 'spelling_enchant', 'SpellingEnchant'), ('osxappkit', 'spelling_osxappkit', 'SpellingOSXAppKit'), ))
`word` : str 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() method 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() method 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)
'''Stop the video playing''' self._state = '' 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 = '' def update(self): '''Update the video content to texture. Must be called every frame, before draw.''' pass def draw(self): '''Draw the current video on screen''' pass # Load the appropriate provider Video = core_select_lib('video', ( ('gstreamer', 'video_gstreamer', 'VideoGStreamer'), ('pyglet', 'video_pyglet', 'VideoPyglet'), ))
"""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")), )