kivy_options_settings
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
kivy_options_settings [2020/01/14 09:35] – créée serge | kivy_options_settings [2020/10/19 07:13] (Version actuelle) – Tag0 Added: python Removed: python3 serge | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
**[[http:// | **[[http:// | ||
</ | </ | ||
+ | <WRAP center round box 40% centeralign> | ||
+ | **[[les_pages_kivy_en_details|Les pages Kivy en détails]]** | ||
+ | </ | ||
+ | =====Ressources===== | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | =====Un exemple et des commentaires pertinents comme explications===== | ||
+ | **Tiré de [[https:// | ||
+ | <code python settings_wiki.py> | ||
+ | #! / | ||
+ | # -*- coding: utf-8 -*- | ||
- | <code python | + | import kivy |
+ | kivy.require(' | ||
+ | from kivy.app import App | ||
+ | from kivy.uix.button import Button | ||
+ | |||
+ | # Pour l' | ||
+ | GLOBAL_DICT = {} | ||
+ | |||
+ | class MyApp(App): | ||
+ | def build(self): | ||
+ | """ | ||
+ | |||
+ | settings_button = Button(text=' | ||
+ | settings_button.bind(on_press=self.open_settings) | ||
+ | return settings_button | ||
+ | |||
+ | def on_start(self): | ||
+ | """ | ||
+ | pass | ||
+ | |||
+ | def build_config(self, | ||
+ | """ | ||
+ | Si le fichier *.ini n' | ||
+ | il est créé avec ces valeurs par défaut. | ||
+ | Il s' | ||
+ | Si il manque seulement des lignes, il ne fait rien ! | ||
+ | """ | ||
+ | |||
+ | print(" | ||
+ | |||
+ | config.setdefaults(' | ||
+ | { ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | config.setdefaults(' | ||
+ | { ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | config.setdefaults(' | ||
+ | { ' | ||
+ | ' | ||
+ | |||
+ | print(" | ||
+ | |||
+ | def build_settings(self, | ||
+ | """ | ||
+ | les réglages Kivy sont par défaut. | ||
+ | |||
+ | Cette méthode est appelée par app.open_settings() dans .kv, | ||
+ | donc si Options est cliqué ! | ||
+ | Les types contrôlent les saisies, mais pas les desc ne contrôlent pas. | ||
+ | """ | ||
+ | |||
+ | print(" | ||
+ | |||
+ | data = """ | ||
+ | {" | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | |||
+ | {" | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | |||
+ | # self.config est le config de build_config | ||
+ | settings.add_json_panel(' | ||
+ | |||
+ | def on_config_change(self, | ||
+ | """ | ||
+ | menu = self.screen_manager.get_screen(" | ||
+ | """ | ||
+ | |||
+ | if config is self.config: | ||
+ | token = (section, key) | ||
+ | |||
+ | # Frequency | ||
+ | if token == (' | ||
+ | GLOBAL_DICT[" | ||
+ | |||
+ | # Cast | ||
+ | if token == (' | ||
+ | print(" | ||
+ | # TODO ... etc ... | ||
+ | |||
+ | def do_quit(self): | ||
+ | print(" | ||
+ | |||
+ | # Kivy | ||
+ | ServerKivyApp.get_running_app().stop() | ||
+ | |||
+ | # Extinction forcée de tout, si besoin | ||
+ | os._exit(0) | ||
+ | | ||
+ | MyApp().run() | ||
</ | </ | ||
+ | |||
+ | {{tag> kivy python sb }} |
kivy_options_settings.1578994535.txt.gz · Dernière modification : 2020/01/14 09:35 de serge