kivy_comment_faire_un_tas_de_chose
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_comment_faire_un_tas_de_chose [2020/11/13 09:25] – [Comment passer d'une class à une autre] serge | kivy_comment_faire_un_tas_de_chose [2022/11/19 09:49] (Version actuelle) – [Sur internet] serge | ||
|---|---|---|---|
| Ligne 10: | Ligne 10: | ||
| ====Sur internet==== | ====Sur internet==== | ||
| * Dans la **[[https:// | * Dans la **[[https:// | ||
| - | * Dans un moteur de recherche: ça finit souvent par des posts sur stackoverflow, | + | * Dans un moteur de recherche: ça finit souvent par des posts sur stackoverflow, |
| + | * **[[https:// | ||
| ====Une bonne solution: Les exemples des sources de kivy==== | ====Une bonne solution: Les exemples des sources de kivy==== | ||
| * Télécharger les sources sur [[https:// | * Télécharger les sources sur [[https:// | ||
| * Dans votre EDI créer un projet avec uniquement les [[https:// | * Dans votre EDI créer un projet avec uniquement les [[https:// | ||
| * Rechercher dans les fichiers: si vous chercher " | * Rechercher dans les fichiers: si vous chercher " | ||
| - | * | + | |
| ====Gallery of Examples==== | ====Gallery of Examples==== | ||
| **[[https:// | **[[https:// | ||
| Ligne 46: | Ligne 46: | ||
| * Sur votre PC, définir la taille de votre fenêtre | * Sur votre PC, définir la taille de votre fenêtre | ||
| <code python> | <code python> | ||
| - | from kivy.core.window import Window | + | from plyer import utils |
| - | # Les 3 lignes ci-dessous sont à commenter pour buildozer | + | |
| - | # L' | + | from oscpy.client import OSCClient |
| - | k = 1.0 | + | from oscpy.server import OSCThreadServer |
| - | WS = (int(1280*k), int(720*k)) | + | |
| - | Window.size = WS | + | print(" |
| + | ANDROID = utils.platform._platform_android | ||
| + | print(" | ||
| + | if not ANDROID: | ||
| + | | ||
| + | # Simulation de l' | ||
| + | k = 0.8 | ||
| + | WS = (int(720*k), int(1280*k)) | ||
| + | Window.size = WS | ||
| + | os.environ[' | ||
| + | |||
| + | from jnius import autoclass | ||
| </ | </ | ||
| Ligne 115: | Ligne 126: | ||
| class Screen2: | class Screen2: | ||
| def __init__(self): | def __init__(self): | ||
| - | self.app = App.get_running_app() # dans __init__() | + | self.app = App.get_running_app() |
| # et appel de l' | # et appel de l' | ||
| self.app.osc.histo | self.app.osc.histo | ||
| Ligne 250: | Ligne 261: | ||
| ni | ni | ||
| requirements = python3, | requirements = python3, | ||
| + | </ | ||
| mais | mais | ||
| + | <code python> | ||
| requirements = python3, | requirements = python3, | ||
| #,jnius | #,jnius | ||
| </ | </ | ||
| - | Le buildozer.spec est seulement presque du python. Ce commentaire m'a donné des message | + | Le buildozer.spec est seulement presque du python. Ce commentaire |
| =====Bugs===== | =====Bugs===== | ||
| Ligne 264: | Ligne 277: | ||
| sudo apt install xclip | sudo apt install xclip | ||
| | | ||
| + | =====Comment avoir une action maintenue si maintien d'un Button===== | ||
| + | <code python accelerometer.kv> | ||
| + | Button: | ||
| + | id: recul | ||
| + | markup: True | ||
| + | background_color: | ||
| + | font_size: " | ||
| + | text: ' | ||
| + | on_press: root.do_back_forward(-1) | ||
| + | on_release: root.do_end() | ||
| + | Button: | ||
| + | id: avance | ||
| + | markup: True | ||
| + | background_color: | ||
| + | font_size: " | ||
| + | text: ' | ||
| + | on_press: root.do_back_forward(1) | ||
| + | on_release: root.do_end() | ||
| + | </ | ||
| + | |||
| + | <code python main.py> | ||
| + | def do_back_forward(self, | ||
| + | self.bf = 1 | ||
| + | bt = Thread(target=self.back_forward_loop, | ||
| + | bt.start() | ||
| + | |||
| + | def back_forward_loop(self, | ||
| + | while self.bf: | ||
| + | sleep(0.1) | ||
| + | self.gap = self.gap + sens*10 | ||
| + | if self.gap > 0: self.gap = 0 | ||
| + | l = len(self.app.osc.histo_xyz) | ||
| + | if self.gap < -l + 500: self.gap = -l + 500 | ||
| + | print(" | ||
| + | |||
| + | def do_end(self): | ||
| + | self.bf = 0 | ||
| + | </ | ||
| + | |||
| {{tag> kivy python sb }} | {{tag> kivy python sb }} | ||
kivy_comment_faire_un_tas_de_chose.1605259527.txt.gz · Dernière modification : de serge
