Outils pour utilisateurs

Outils du site


kivy_image_avec_alpha_sur_fond_blanc

Ceci est une ancienne révision du document !


Kivy: Une image avec canal alpha sur un fond blanc dans un BoxLayout

Arrière plan blanc sous une image avec canal alpha

fond_blanc.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
 
import kivy
kivy.require('1.11.1')
 
from kivy.app import App
from kivy.uix.screenmanager import Screen
from kivy.properties import ListProperty
from kivy.lang import Builder
 
Builder.load_string('''
<Main>:
    BoxLayout:
        canvas.before:
            Color:
                rgb: 1, 1, 1
            Rectangle:
                size: self.size
                pos: self.pos
        canvas:
            Rectangle:
                # self.size = taille du BoxLayout
                size: root.taille
                pos: 200, 200
                source: "labo.png"
''')
 
class Main(Screen):
    # Attibut de class accessible dans kv avec root.taille
    taille = ListProperty([200, 200])
 
    # taille peut être modifié ensuite avec l'attribut self.taille
 
class FondBlancApp(App):
    def build(self):
        return Main()
 
if __name__ == '__main__':
    FondBlancApp().run()
,
kivy_image_avec_alpha_sur_fond_blanc.1577968725.txt.gz · Dernière modification : 2020/01/02 12:38 de serge