Outils pour utilisateurs

Outils du site


kivy_image_avec_alpha_sur_fond_blanc

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
kivy_image_avec_alpha_sur_fond_blanc [2020/01/02 11:04] – créée sergekivy_image_avec_alpha_sur_fond_blanc [2020/01/18 11:08] – [Arrière plan blanc sous une image avec canal alpha] serge
Ligne 5: Ligne 5:
 </WRAP> </WRAP>
  
 +{{ ::kivy_fond_blanc.png?400 |}}
 +===== Arrière plan blanc sous une image avec canal alpha=====
  
-=====Quel est le problème=====+<code python fond_blanc.py> 
 +#! /usr/bin/env python3 
 +# -*- coding: utf-8 -*-
  
 +import kivy
 +kivy.require('1.11.1')
  
-{{tag>kivy sb}}+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() 
 +</code> 
 + 
 +{{tag>kivy sb python3}}
kivy_image_avec_alpha_sur_fond_blanc.txt · Dernière modification : 2020/10/29 13:50 de serge