Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.
La shoutbox n'est pas chargée par défaut pour des raisons de performances. Cliquez pour charger.

Forum Casio - Autres questions


Index du Forum » Autres questions » Python input and casioplot
Calamari Hors ligne Membre Points: 229 Défis: 0 Message

Python input and casioplot

Posté le 20/08/2022 05:42

In the fx-9750GIII's stock Python add-in, I was hoping to use input while on the graphics screen. Unfortunately, as soon as input() runs, it switches back to the text screen. That behavior is printed in the User's Guide, so I suppose it is what it is. This does make it difficult for interactivity, tho.

My current workaround is to add an empty for loop with range(100000). That pauses the screen a bit before the input yanks it away. Then, anytime the len() is 0 (pressed EXE) it does another show_screen() and pauses again. That way I can see the screen as long as I want, albeit with brief interruptions.

Has anyone has come up with a better way? I might eventually port it to C and use fxsdk, then I'd have full control of the screen, non-blocking input, etc. The program is so large now that I cannot even edit it on the calculator, so there's not much reason not to. Even so, I'm still curious if there's a solution in Python.


Lephenixnoir Hors ligne Administrateur Points: 24223 Défis: 170 Message

Citer : Posté le 20/08/2022 08:11 | #


I don't exactly understand how your solution works. If you run the for loop after the input() then you still have a blocking wait on the terminal for the user to type something. If you run it before the input() then pressing EXE does not pre-validate the input() AFAIK?

The only common trick for user input is to get the user to press AC/ON and then catch the KeyboardInterrupt. In Chute tridimensionnelle I extended the concept a bit further by using nested try/catch in a way that I can detect, single, double and triple AC/ON presses to represent two actions and an interrupt respectively. But you could also just wait for AC/ON to be pressed to run input() which switches to the terminal.
Mon graphe (11 Avril): ((Rogue Life || HH2) ; PythonExtra ; serial gint ; Boson X ; passe gint 3 ; ...) || (shoutbox v5 ; v5)
Calamari Hors ligne Membre Points: 229 Défis: 0 Message

Citer : Posté le 20/08/2022 08:24 | #


I must have explained it badly, but it really does not matter, because you've solved it, and my hack is unnecessary. Now I can stay on the graphics screen until I choose to leave by pressing AC.

Thanks a lot!

LienAjouter une imageAjouter une vidéoAjouter un lien vers un profilAjouter du codeCiterAjouter un spoiler(texte affichable/masquable par un clic)Ajouter une barre de progressionItaliqueGrasSoulignéAfficher du texte barréCentréJustifiéPlus petitPlus grandPlus de smileys !
Cliquez pour épingler Cliquez pour détacher Cliquez pour fermer
Alignement de l'image: Redimensionnement de l'image (en pixel):
Afficher la liste des membres
:bow: :cool: :good: :love: ^^
:omg: :fusil: :aie: :argh: :mdr:
:boulet2: :thx: :champ: :whistle: :bounce:
valider
 :)  ;)  :D  :p
 :lol:  8)  :(  :@
 0_0  :oops:  :grr:  :E
 :O  :sry:  :mmm:  :waza:
 :'(  :here:  ^^  >:)

Σ π θ ± α β γ δ Δ σ λ
Veuillez donner la réponse en chiffre
Vous devez activer le Javascript dans votre navigateur pour pouvoir valider ce formulaire.

Si vous n'avez pas volontairement désactivé cette fonctionnalité de votre navigateur, il s'agit probablement d'un bug : contactez l'équipe de Planète Casio.

Planète Casio v4.3 © créé par Neuronix et Muelsaco 2004 - 2024 | Il y a 45 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements

Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd