kivy_liste_des_elements_graphiques_widgets_de_comportement_et_gestion_d_ecrans
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
kivy_liste_des_elements_graphiques_widgets_de_comportement_et_gestion_d_ecrans [2018/07/24 11:36] – serge | kivy_liste_des_elements_graphiques_widgets_de_comportement_et_gestion_d_ecrans [2020/12/01 17:43] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
======Kivy: Liste des éléments graphiques Widgets de comportement et Gestion d' | ======Kivy: Liste des éléments graphiques Widgets de comportement et Gestion d' | ||
+ | <WRAP center round box 60% centeralign> | ||
+ | **{{tagpage> | ||
+ | **[[http:// | ||
+ | </ | ||
+ | <WRAP center round box 40% centeralign> | ||
+ | **[[les_pages_kivy_en_details|Les pages Kivy en détails]]** | ||
+ | </ | ||
===== Screen manager ===== | ===== Screen manager ===== | ||
- | Gérer plusieurs écrans: options, menu ... {{:Screenmanager1.png? | + | Gérer plusieurs écrans: options, menu ... {{media_12:screenmanager1.png? |
- | <code python> | + | <code python |
#! / | #! / | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Ligne 45: | Ligne 51: | ||
ScreenmanagerApp().run() | ScreenmanagerApp().run() | ||
</ | </ | ||
- | **screenmanager.kv** | ||
- | <code python> | + | <code python |
#:kivy 1.8.0 | #:kivy 1.8.0 | ||
Ligne 77: | Ligne 82: | ||
Il faut toujours que la doc rajoute des notions nouvelles dans l' | Il faut toujours que la doc rajoute des notions nouvelles dans l' | ||
- | <code python> | + | <code python |
#! / | #! / | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Ligne 102: | Ligne 107: | ||
==== Avec kv, sans notions nouvelles ==== | ==== Avec kv, sans notions nouvelles ==== | ||
- | **carousel_1.py** | + | <code python |
- | + | ||
- | <code python> | + | |
#! / | #! / | ||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||
Ligne 110: | Ligne 113: | ||
import kivy | import kivy | ||
kivy.require(' | kivy.require(' | ||
- | |||
from kivy.app import App | from kivy.app import App | ||
from kivy.uix.screenmanager import ScreenManager, | from kivy.uix.screenmanager import ScreenManager, | ||
from kivy.uix.carousel import Carousel | from kivy.uix.carousel import Carousel | ||
+ | from kivy.clock import Clock | ||
+ | |||
+ | class Nothing: | ||
+ | def print_some(self, | ||
+ | print(some) | ||
class MainScreen(Screen): | class MainScreen(Screen): | ||
pass | pass | ||
- | class Screen1(Screen): | + | class Screen1(Screen, Nothing): |
- | | + | |
+ | super().__init__(**kwargs) | ||
+ | # Cet objet (donc self!) hérite des méthodes et attributs de Nothing | ||
+ | self.print_some(" | ||
class Screen2(Screen): | class Screen2(Screen): | ||
- | pass | ||
- | |||
- | class Screen3(Screen): | ||
- | pass | ||
- | |||
- | class Screen4(Screen): | ||
- | pass | ||
- | |||
- | class SettingsScreen(Screen): | ||
- | pass | ||
- | |||
- | class JsonScreen(Screen): | ||
- | pass | ||
- | |||
- | class OpenScreen(Screen): | ||
pass | pass | ||
SCREENS = { 0: (MainScreen, | SCREENS = { 0: (MainScreen, | ||
1: (Screen1, | 1: (Screen1, | ||
- | 2: (Screen2, | + | 2: (Screen2, |
- | 3: (Screen3, | + | |
- | 4: (Screen4, | + | |
- | 5: (SettingsScreen, | + | |
- | 6: (JsonScreen, | + | |
- | 7: (OpenScreen, | + | |
- | } | + | |
- | class Carousel_1App(App): | + | class Carousel_ExApp(App): |
def build(self): | def build(self): | ||
carousel = Carousel(direction=' | carousel = Carousel(direction=' | ||
- | for i in range(8): | + | for i in range(3): |
carousel.add_widget(SCREENS[i][0](name=SCREENS[i][1])) | carousel.add_widget(SCREENS[i][0](name=SCREENS[i][1])) | ||
return carousel | return carousel | ||
- | |||
if __name__ == ' | if __name__ == ' | ||
- | | + | |
</ | </ | ||
**carousel_1.kv** | **carousel_1.kv** | ||
Ligne 164: | Ligne 152: | ||
<code python> | <code python> | ||
#:kivy 1.8.0 | #:kivy 1.8.0 | ||
- | |||
< | < | ||
BoxLayout: | BoxLayout: | ||
Ligne 170: | Ligne 157: | ||
text: 'Menu principal' | text: 'Menu principal' | ||
font_size: 36 | font_size: 36 | ||
- | |||
< | < | ||
BoxLayout: | BoxLayout: | ||
Ligne 176: | Ligne 162: | ||
text: 'ecran 1' | text: 'ecran 1' | ||
font_size: 36 | font_size: 36 | ||
- | |||
< | < | ||
BoxLayout: | BoxLayout: | ||
Label: | Label: | ||
text: 'ecran 2' | text: 'ecran 2' | ||
- | font_size: 36 | ||
- | |||
- | < | ||
- | BoxLayout: | ||
- | Label: | ||
- | text: 'ecran 3' | ||
- | font_size: 36 | ||
- | |||
- | < | ||
- | BoxLayout: | ||
- | Label: | ||
- | text: 'ecran 4' | ||
- | font_size: 36 | ||
- | |||
- | < | ||
- | BoxLayout: | ||
- | Label: | ||
- | text: "Mon bouton d' | ||
- | font_size: 36 | ||
- | |||
- | < | ||
- | BoxLayout: | ||
- | Label: | ||
- | text: "Mon bouton d' | ||
- | font_size: 36 | ||
- | |||
- | < | ||
- | BoxLayout: | ||
- | Label: | ||
- | text: " | ||
font_size: 36 | font_size: 36 | ||
</ | </ | ||
- | {{tag> | + | {{tag> kivy python |
kivy_liste_des_elements_graphiques_widgets_de_comportement_et_gestion_d_ecrans.1532432210.txt.gz · Dernière modification : 2018/07/24 11:36 de serge