Outils pour utilisateurs

Outils du site


kivy_comment_faire_un_tas_de_chose

Différences

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

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
kivy_comment_faire_un_tas_de_chose [2020/01/15 08:23] – [Comment lister tous les widgets dans le python] sergekivy_comment_faire_un_tas_de_chose [2020/10/19 07:10] – Tag0 Added: python Removed: python3 serge
Ligne 1: Ligne 1:
-======Kivy: Comment faire un tas de chose======+======Kivy: Comment faire un tas de chose ======
 <WRAP center round box 60% centeralign> <WRAP center round box 60% centeralign>
 **{{tagpage>kivy|Toutes les pages Kivy}}**   **{{tagpage>kivy|Toutes les pages Kivy}}**  
 **[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_comment_faire_un_tas_de_chose|English Version]]** **[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_comment_faire_un_tas_de_chose|English Version]]**
 </WRAP> </WRAP>
-===== Pourquoi kivy est-il traître ? =====+<WRAP center round box 40% centeralign> 
 +**[[les_pages_kivy_en_details|Les pages Kivy en détails]]** 
 +</WRAP> 
 +===== Comment chercher ? ===== 
 +====Sur internet==== 
 +  * Dans la **[[https://kivy.org/doc/stable/|doc officielle]]**, mais les chances de trouver sont quasi nulles. 
 +  * Dans un moteur de recherche: ça finit souvent par des posts sur stackoverflow, avec des réponses <del>médiocres</del> fausses, uniquement motivées par le gain de points !
  
-**Kivy masque des erreurs python**+====Une bonne solution: Les exemples des sources de kivy==== 
 +  Télécharger les sources sur [[https://github.com/kivy/kivy|github]] 
 +  Dans votre EDI créer un projet avec uniquement les [[https://github.com/kivy/kivy/tree/master/examples|exemples]] 
 +  * Rechercher dans les fichiers: si vous chercher "source:", vous aurez la liste de tous les fichiers qui utilisent "source:". Si c'est un kv, trouver le .py corespondant pour l'exécuter. 
 + 
 +=====Des explications avec les exemples des sources===== 
 +Une liste de scripts qui explique bien: 
 + 
 +  * **pos_hint** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/boxlayout_poshint.py|boxlayout_poshint.py]] 
 +  * **bubble** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/bubble_test.py|bubble_test.py]] 
 +  * **camera** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/camera.py|camera.py]] 
 +  * **carousel** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/carousel_buttons.py|carousel_buttons.py]] 
 +  * **mipmap** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/label_mipmap.py|label_mipmap.py]] 
 +  * **text_size = textwrap** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/label_text_size.py|label_text_size.py]] 
 +  * **text with markup** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/label_with_markup.py|label_with_markup.py]] 
 +  * **popup** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/popup_with_kv.py|popup_with_kv.py]] 
 +  * **scatter** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/scatter.py|scatter.py]] et [[https://github.com/kivy/kivy/blob/master/examples/widgets/scatter.kv|scatter.kv]] 
 +  * **scrollview** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/scrollview.py|scrollview.py]] et [[https://github.com/kivy/kivy/blob/master/examples/widgets/scrollview.kv|scrollview.kv]] 
 +  * **splitter** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/splitter.py|splitter.py]] 
 +  * **tabbed panel = onglet** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/tabbedpanel.py|tabbedpanel.py]] 
 +  * **text align** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/textalign.py|textalign.py]] [[https://github.com/kivy/kivy/blob/master/examples/widgets/textalign.kv|textalign.kv]] 
 +  * **video player** : [[https://github.com/kivy/kivy/blob/master/examples/widgets/videoplayer.py|videoplayer.py]] 
 +  * **ErrorPopup(Popup)** : [[https://github.com/kivy/plyer/blob/master/examples/text2speech/main.py|main.py]] et [[https://github.com/kivy/plyer/blob/master/examples/text2speech/text2speechdemo.kv|text2speechdemo.kv]] 
 +  * **Slider** : [[https://github.com/kivy/kivy/blob/master/examples/canvas/circle.py|circle.py]] 
 +  * **Clock** : [[https://github.com/kivy/kivy/blob/master/examples/tutorials/pong/main.py|Pong]] ou [[https://github.com/kivy/kivy/blob/master/examples/canvas/mesh_manipulation.py|mesh_manipulation.py]] 
 + 
 + 
 + 
 + 
 +=====Adapter la résolution dpi sur son PC===== 
 +  * Sur votre PC, définir la taille de votre fenêtre 
 +<code python
 +from kivy.core.window import Window 
 +# Les 3 lignes ci-dessous sont à commenter pour buildozer 
 +# L'écran de mon tél fait 1280*720 
 +k = 1.0 
 +WS = (int(1280*k), int(720*k)) 
 +Window.size = WS 
 +</code>
  
-Par exemple:+Lancer le main.py avec: 
 +  KIVY_METRICS_FONTSCALE=1.2 python3 main.py 
 +avec une valeur "1.2" à adapter pour que vous ayez le même graphisme sur votre PC que sur votre téléphone.
  
-  * un argument qui manque dans un appel de méthode lève une erreur pour du python habituel, mais pas dans kivy. D'où un débogage rusé nécessaire ! 
  
 =====Comment lister tous les widgets dans le python===== =====Comment lister tous les widgets dans le python=====
Ligne 22: Ligne 67:
   print([type(widget) for widget in f.walk(loopback=True)])   print([type(widget) for widget in f.walk(loopback=True)])
      
-Sortie de [type(widget) for widget in self.walk(loopback=True)]+Sortie de [type(widget) for widget in self.walk(loopback=True)] dans SmartCitizen()
 <code> <code>
 <class '__main__.SmartCitizen'>, <class '__main__.SmartCitizen'>,
Ligne 34: Ligne 79:
 <class 'kivy.uix.label.Label'>, <class 'kivy.uix.label.Label'>,
 <class 'kivy.uix.boxlayout.BoxLayout'>, <class 'kivy.uix.boxlayout.BoxLayout'>,
-<class 'kivy.uix.boxlayout.BoxLayout'>, +......
-<class 'kivy.uix.gridlayout.GridLayout'>, +
-<class 'kivy.uix.boxlayout.BoxLayout'>, +
-<class 'kivy.uix.button.Button'>, +
-<class 'kivy.uix.boxlayout.BoxLayout'>, +
-<class 'kivy.uix.boxlayout.BoxLayout'>+
 </code> </code>
 =====Comment passer d'une class à une autre===== =====Comment passer d'une class à une autre=====
Ligne 51: Ligne 91:
  
  
-===== La commande magique ===== 
- 
-Dans Blender, le raccourcis magique c'est: 
-**Ctrl + A** Apply the object's transformation to its data 
- 
-Dans le *.kv, c'est: [[https://kivy.org/docs/api-kivy.lang.html|Graphical Instructions]] 
- 
-<code python> 
-    canvas: 
-        Clear 
-</code> 
  
  
Ligne 133: Ligne 162:
     ...     ...
 </code> </code>
 +
 +=====Button background_color=====
 +<code python>
 +Button:
 +    background_normal: ''
 +    background_color: 1, .3, .4, .85
 +</code>
 +
 +=====Texte en gras dans un label=====
 +  * **[[https://kivy.org/doc/stable/api-kivy.core.text.markup.html|Text Markup]]**
 +<code python>
 +        Label:
 +            canvas.before:
 +                Color:
 +                    rgba: 1, 1, 1, 1
 +                Rectangle:
 +                    pos: self.pos
 +                    size: self.size
 +            size_hint_y: 0.10
 +            markup: True
 +            text: '[b]' + "Mon texte" + '[/b]'
 +            color: 1, 0, 0.5, 1
 +</code>
 +
 +
 ===== Factory ===== ===== Factory =====
 Factory peut être utilisée pour enregistrer automatiquement toute classe ou module et en instancier des classes n'importe où dans votre projet. Factory peut être utilisée pour enregistrer automatiquement toute classe ou module et en instancier des classes n'importe où dans votre projet.
  
-  * **[[http://kivy.org/docs/api-kivy.factory.html|API Factory]]** [[https://stackoverflow.com/questions/29592280/using-factory-objects-in-kivy|using-factory-objects-in-kivy]] î'm not sure of everything the Factory is used for ...Dans les exemples, c'est utilisé pour enregistrer des widgets, dans des trucs sans kv.+  * **[[http://kivy.org/docs/api-kivy.factory.html|API Factory]]** [[https://stackoverflow.com/questions/29592280/using-factory-objects-in-kivy|using-factory-objects-in-kivy]] I'm not sure of everything the Factory is used for ... Les exemples de la doc qui l'utilisent sont irréels ...
 ===== Réception sur Android en Multicast ===== ===== Réception sur Android en Multicast =====
  
Ligne 150: Ligne 204:
  
  
-{{tag>kivy sb}}+{{tag> kivy python sb }}
kivy_comment_faire_un_tas_de_chose.txt · Dernière modification : 2022/11/19 09:49 de serge