Python kivy.uix.image.Image() Examples
The following are 23
code examples of kivy.uix.image.Image().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
kivy.uix.image
, or try the search function
.
Example #1
Source File: dashboardview.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
def __init__(self, settings, dashboard_factory, **kwargs): super(DashboardScreenPreferences, self).__init__(**kwargs) self._settings = settings current_screens = self._settings.userPrefs.get_dashboard_screens() screen_keys = dashboard_factory.available_dashboards for key in screen_keys: [name, image] = dashboard_factory.get_dashboard_preview_image_path(key) checkbox = CheckBox() checkbox.active = True if key in current_screens else False checkbox.bind(active=lambda i, v, k=key:self._screen_selected(k, v)) screen_item = DashboardScreenItem() screen_item.add_widget(checkbox) screen_item.add_widget(FieldLabel(text=name)) screen_item.add_widget(Image(source=image)) self.ids.grid.add_widget(screen_item) self._current_screens = current_screens
Example #2
Source File: preview.py From pi-scan with BSD 2-Clause "Simplified" License | 6 votes |
def redisplay(self, root): if self.result.code == preview_thread.COMPLETE: root.cols = self.result.columnCount while len(root.children) > len(self.result.data): root.remove_widget(root.children[-1]) while len(root.children) < len(self.result.data): root.add_widget(Image()) for i in xrange(0, len(self.result.data)): current = root.children[i] if len(self.textures) <= i: self.textures.append(Texture.create_from_data(self.result.data[i])) self.textures[i].flip_vertical() else: self.textures[i].blit_data(self.result.data[i]) current.texture = None current.texture = self.textures[i] current.size_hint = (1.0*self.result.sizes[i][0]/self.result.width, 1.0*self.result.sizes[i][1]/self.result.height) root.width = root.height * self.result.width / self.result.height #root.height = root.width * self.result.height / self.result.width else: root.clear_widgets()
Example #3
Source File: screenexporting.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def update_test_image(self, *_): """Regenerate the watermark preview image.""" if self.watermark_settings: test_image = self.watermark_settings.ids['testImage'] test_image.clear_widgets() if os.path.isfile(self.watermark_image): image = KivyImage(source=self.watermark_image) size_x = test_image.size[0]*(self.watermark_size/100) size_y = test_image.size[1]*(self.watermark_size/100) image.size = (size_x, size_y) image.size_hint = (None, None) image.opacity = self.watermark_opacity/100 x_pos = test_image.pos[0]+((test_image.size[0] - size_x)*(self.watermark_horizontal/100)) y_pos = test_image.pos[1]+((test_image.size[1] - size_y)*(self.watermark_vertical/100)) image.pos = (x_pos, y_pos) test_image.add_widget(image)
Example #4
Source File: main.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def new_game(self): if use_ads: revmob.show_popup() self.content.clear_widgets() self.content.add_widget(Image(source='assets/graphics/ui/loading.png', size=Window.size, allow_stretch=True)) Clock.schedule_once(self.post_splash)
Example #5
Source File: block.py From Persimmon with MIT License | 5 votes |
def __init__(self, **kwargs): super().__init__(**kwargs) # Reverse ids on class because dict ordering is reversed ids = list(self.ids.values())[::-1] self.input_pins = [x.__self__ for x in ids if issubclass(x.__class__, InputPin)] self.output_pins = [x.__self__ for x in ids if issubclass(x.__class__, OutputPin)] for pin in self.input_pins: pin.block = self self.gap = pin.width * 2 for pin in self.output_pins: pin.block = self self.gap = pin.width * 2 self.tainted_msg = 'Block {} has unconnected inputs'.format(self.title) self._tainted = False self.kindled = None self.border_texture = Image(source='persimmon/border.png').texture # Make block taller if necessary self.height = (max(len(self.output_pins), len(self.input_pins), 3) * self.gap + self.label.height) # Position pins nicely #y_origin = self.y + (self.height - self.label.height) for i, in_pin in enumerate(list(self.input_pins[::-1]), 1): self._bind_pin(self, (in_pin.x, in_pin.y), in_pin, i, False) self.fbind('pos', self._bind_pin, pin=in_pin, i=i, output=False) for i, out_pin in enumerate(list(self.output_pins[::-1]), 1): self._bind_pin(self, (out_pin.x, out_pin.y), out_pin, i, True) self.fbind('pos', self._bind_pin, pin=out_pin, i=i, output=True)
Example #6
Source File: view.py From Persimmon with MIT License | 5 votes |
def build(self): print('Building main view') self.title = 'Persimmon' self.background = Image(source='persimmon/background.png').texture
Example #7
Source File: main.py From python-examples with MIT License | 5 votes |
def build(self): return Image(source='image.png')
Example #8
Source File: HexTile.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_mod_layer(self): mod_type = choice(mod_layers) self.mod_layer = Image(source='assets/graphics/tiles/' + mod_type + '.png', pos=(self.x, self.y + 204), size=(120, 210)) self.add_widget(self.mod_layer)
Example #9
Source File: HexTile.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_star(self): self.star = Image(source='assets/graphics/tiles/starGold.png', pos=(self.x + STAR_POS[0], self.y + STAR_POS[1] + 204)) self.add_widget(self.star)
Example #10
Source File: HexTile.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_key(self): self.key = Image(source='assets/graphics/tiles/' + self.key_type + '.png', pos=(self.x + 20, self.y + 274)) self.add_widget(self.key)
Example #11
Source File: HexTile.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_portal(self): self.portal = Image(source='assets/graphics/tiles/portal.png', pos=(self.x + 10, self.y + 264)) self.add_widget(self.portal)
Example #12
Source File: MapCanvas.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_too_far_splash(self): self.tile_too_far_splash = Image(source='assets/graphics/ui/tileTooFar.png', size_hint=(1, 1), pos_hint={'x': 0, 'y': 0}) self.add_widget(self.tile_too_far_splash)
Example #13
Source File: MapCanvas.py From hexTap with BSD 3-Clause "New" or "Revised" License | 5 votes |
def show_enemy_turn_splash(self): self.enemy_turn_splash = Image(source='assets/graphics/ui/enemyTurn.png', size_hint=(1, 1), pos_hint={'x': 0, 'y': 0}) self.add_widget(self.enemy_turn_splash)
Example #14
Source File: viewer.py From kivy-smoothie-host with GNU General Public License v3.0 | 5 votes |
def loading(self, ll=1): self.valid = False self.li = Image(source='img/image-loading.gif') self.add_widget(self.li) self.ids.surface.canvas.remove(self.canv) threading.Thread(target=self._load_file, args=(ll,)).start()
Example #15
Source File: bubble.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._prev_arrow_pos = None self._arrow_layout = BoxLayout() self._bk_img = Image( source=self.background_image, allow_stretch=True, keep_ratio=False, color=self.background_color) self.background_texture = self._bk_img.texture self._arrow_img = Image(source=self.arrow_image, allow_stretch=True, color=self.background_color) self.content = content = BubbleContent(parent=self) super(Bubble, self).__init__(**kwargs) content.parent = None self.add_widget(content) self.on_arrow_pos()
Example #16
Source File: bubble.py From Tickeys-linux with MIT License | 5 votes |
def __init__(self, **kwargs): self._prev_arrow_pos = None self._arrow_layout = BoxLayout() self._bk_img = Image( source=self.background_image, allow_stretch=True, keep_ratio=False, color=self.background_color) self.background_texture = self._bk_img.texture self._arrow_img = Image(source=self.arrow_image, allow_stretch=True, color=self.background_color) self.content = content = BubbleContent(parent=self) super(Bubble, self).__init__(**kwargs) content.parent = None self.add_widget(content) self.on_arrow_pos()
Example #17
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def _load_fullsize(self): app = App.get_running_app() if not self.lowmem: low_memory = to_bool(app.config.get("Settings", "lowmem")) else: low_memory = True if not low_memory: #load a screen-sized image instead of full-sized to save memory if os.path.splitext(self.source)[1].lower() == '.bmp': #default image loader messes up bmp files, use pil instead self._coreimage = ImageLoaderPIL(self.source) else: self._coreimage = KivyImage(source=self.source) else: #load and rescale image original_image = Image.open(self.source) image = original_image.copy() original_image.close() resize_width = Window.size[0] if image.size[0] > resize_width: width = int(resize_width) height = int(resize_width * (image.size[1] / image.size[0])) if width < 10: width = 10 if height < 10: height = 10 image = image.resize((width, height)) if image.mode != 'RGB': image = image.convert('RGB') image_bytes = BytesIO() image.save(image_bytes, 'jpeg') image_bytes.seek(0) self._coreimage = CoreImage(image_bytes, ext='jpg') self.texture = self._coreimage.texture if self.mirror: self.texture.flip_horizontal()
Example #18
Source File: tour3d.py From kivy3dgui with MIT License | 5 votes |
def __init__(self, **kwargs): wpos = self.pos = kwargs.pop("pos") try: self.create_image = kwargs.pop("create_image") super(Note, self).__init__(**kwargs) except: print(kwargs) self.opacity = 0 #Show anim = Animation(opacity=1.0, duration=0.3) anim.start(self) create_image = kwargs.get('create_image', False) self.request_del = False text_editor = TextInput(size = (120, 90)) close = Button(size = (20, 20), text="x") image = Image(source="./data/imgs/background.jpg", allow_stretch=True, keep_ratio=False) self.add_widget(image) self.add_widget(text_editor) self.add_widget(close) if create_image: image_front = Image(source="./data/imgs/faust_github.jpg", size=(120,70), allow_stretch=True, keep_ratio=False) self.add_widget(image_front) self.size = (120, 120) self.size_hint = (None, None) image.size = (120, 120) text_editor.pos = (0, 10) close.pos = (100, 100) self.pos = wpos close.bind(on_release=self.close_request)
Example #19
Source File: layout3d.py From kivy3dgui with MIT License | 5 votes |
def on_touch_up(self, touch): ret = False for e in self.children: if not isinstance(e, Image): if e.collide_point(touch.x, touch.y): ret = e.on_touch_up(touch) break return ret
Example #20
Source File: loader.py From Tickeys-linux with MIT License | 4 votes |
def image(self, filename, load_callback=None, post_callback=None, **kwargs): '''Load a image using the Loader. A ProxyImage is returned with a loading image. You can use it as follows:: from kivy.app import App from kivy.uix.image import Image from kivy.loader import Loader class TestApp(App): def _image_loaded(self, proxyImage): if proxyImage.image.texture: self.image.texture = proxyImage.image.texture def build(self): proxyImage = Loader.image("myPic.jpg") proxyImage.bind(on_load=self._image_loaded) self.image = Image() return self.image TestApp().run() In order to cancel all background loading, call *Loader.stop()*. ''' data = Cache.get('kv.loader', filename) if data not in (None, False): # found image, if data is not here, need to reload. return ProxyImage(data, loading_image=self.loading_image, loaded=True, **kwargs) client = ProxyImage(self.loading_image, loading_image=self.loading_image, **kwargs) self._client.append((filename, client)) if data is None: # if data is None, this is really the first time self._q_load.appendleft({ 'filename': filename, 'load_callback': load_callback, 'post_callback': post_callback, 'kwargs': kwargs}) if not kwargs.get('nocache', False): Cache.append('kv.loader', filename, False) self._start_wanted = True self._trigger_update() else: # already queued for loading pass return client # # Loader implementation #
Example #21
Source File: loader.py From Tickeys-linux with MIT License | 4 votes |
def image(self, filename, load_callback=None, post_callback=None, **kwargs): '''Load a image using the Loader. A ProxyImage is returned with a loading image. You can use it as follows:: from kivy.app import App from kivy.uix.image import Image from kivy.loader import Loader class TestApp(App): def _image_loaded(self, proxyImage): if proxyImage.image.texture: self.image.texture = proxyImage.image.texture def build(self): proxyImage = Loader.image("myPic.jpg") proxyImage.bind(on_load=self._image_loaded) self.image = Image() return self.image TestApp().run() In order to cancel all background loading, call *Loader.stop()*. ''' data = Cache.get('kv.loader', filename) if data not in (None, False): # found image, if data is not here, need to reload. return ProxyImage(data, loading_image=self.loading_image, loaded=True, **kwargs) client = ProxyImage(self.loading_image, loading_image=self.loading_image, **kwargs) self._client.append((filename, client)) if data is None: # if data is None, this is really the first time self._q_load.appendleft({ 'filename': filename, 'load_callback': load_callback, 'post_callback': post_callback, 'kwargs': kwargs}) if not kwargs.get('nocache', False): Cache.append('kv.loader', filename, False) self._start_wanted = True self._trigger_update() else: # already queued for loading pass return client # # Loader implementation #
Example #22
Source File: layout3d.py From kivy3dgui with MIT License | 4 votes |
def on_post_processing(self, widget, value): if not self._init_request[0]: self._init_request[0] = True self._init_request[1] = value return for children in self.children[:]: if isinstance(children, Canvas3D) or isinstance(children, BlurEffectWidget): self.remove_widget(children) #for children in self.effect_widget.children[:]: # self.effect_widget.remove_widget(children) if value: self.effect_widget = EffectWidget() self.effect_widget.add_widget(self.canvas3d) self.effect_widget.effects = [FXAAEffect()] self.effect_widget.size = (1366, 768) effect = Image(size_hint=(1.0, 1.0), allow_stretch=True, keep_ratio=False) effect.texture = self.canvas3d.canvas.texture self.effect_widget.add_widget(effect) self.add_widget(self.effect_widget, 100000) self.remove_widget(self.render_texture) effect.texture.mag_filter = 'linear' effect.texture.min_filter = 'linear' self.effect_widget.texture.mag_filter = 'linear' self.effect_widget.texture.min_filter = 'linear' # self.effect_widget.add_widget(self.canvas3d) # self.effect_widget.effect_mask = self.canvas3d.picking_fbo # self.add_widget(self.effect_widget) else: if self.effect_widget: if self.canvas3d in self.effect_widget.children: self.effect_widget.remove_widget(self.canvas3d) self.remove_widget(self.effect_widget) self.add_widget(self.canvas3d, 100000) self.add_widget(self.render_texture, 100000)
Example #23
Source File: layout3d.py From kivy3dgui with MIT License | 4 votes |
def __init__(self, **kwargs): self.canvas_size = kwargs.get("canvas_size", Window.size) super(Layout3D, self).__init__(**kwargs) self._trigger_layout = Clock.create_trigger(self.do_layout, -1) effectwidget.C_SIZE = self.canvas_size with self.canvas.before: Color(1.0, 1.0, 1.0, 1.0) ClearColor(1.0, 1.0, 1.0, 1.0) self.create_canvas() self.bind(look_at=self.canvas3d.setter('look_at')) self.bind(shadow_offset=self.canvas3d.setter('_shadow_offset')) self.bind(shadow_threshold=self.canvas3d.setter('shadow_threshold')) self.bind(shadow_origin=self.canvas3d.setter('_shadow_pos')) self.bind(shadow_target=self.canvas3d.setter('_shadow_target')) self.bind(picking_scale=self.canvas3d.setter('picking_scale')) self.bind(canvas_size=self.canvas3d.setter('canvas_size')) self.bind(ambient_light=self.canvas3d.setter('ambient_light')) self.bind(light_intensity=self.canvas3d.setter('light_intensity')) self.bind(light_position=self.canvas3d.setter('light_position')) self.bind(light_orientation=self.canvas3d.setter('light_orientation')) self.bind(light_0=self.canvas3d.setter('light_0')) self.bind(light_1=self.canvas3d.setter('light_1')) #self.effect_widget = BlurEffectWidget(mask_effect=self.canvas3d.picking_fbo, # motion_effect=self.canvas3d.motion_blur_fbo, # fbo_canvas=self.canvas3d.canvas) self.render_texture = Image(size_hint=(1.0, 1.0), allow_stretch=True, keep_ratio=False) self.add_widget(self.render_texture, 100000) self.render_texture.texture = self.canvas3d.canvas.texture self.render_texture.texture.mag_filter = 'linear' self.render_texture.texture.min_filter = 'linear' if self._init_request[0]: self.post_processing = not self._init_request[1] self.post_processing = self._init_request[1] self._init_request[0] = True from kivy3dgui.canvas3d import label, label_debug label.parent = None try: self.add_widget(label) self.add_widget(label_debug) except Exception as w: pass self.bind(pos=self.render_texture.setter('pos')) self.bind(size=self.render_texture.setter('size'))