Asking for a string/char user input before or inside setup()

edited April 2017 in Python Mode

Hello, I am looking for a way to get a user input before or inside setup(). Specifically, if I can get either "b" or "w" before the codes in setup() start happening, that is all I need. I've found some solutions regarding this but unfortunately they use codes and libraries based on Java, and I am using Python. Any ideas?

In my coding I ask for an image user input in the setup(), using G4P.selectInput(), which I was able to work it out. I am thinking maybe something similar works, and I tried GTextBase.getText() but, I really can't figure out how it works and therefore I don't know how to use it. I don't even know if it works in my case.

Answers

  • As I understand, you can open a dialog box and retrieve a message from the user already. I am not sure if you can use G4P as it could depend on draw. But if you use java AWT then you are half done. I am not familiar with python but I could do something like this in the java side:

    char userInput =' ';

    void settings(){
      //Generate your input  dialog here...
    
      //Next block waits for the user to input a value
      while(userInput !=' '){ delay(100);}
    }
    
    void setup(){  YOUR CODE HERE}
    
    void draw(){  YOUR CODE HERE}
    

    You could get away by using only setup. I just wanted to show you the existence of settings as an additional function that exist in Processing and that runs right before setup. However, I am not sure if you can use it in python.

    Kf

  • Answer ✓

    Thanks guys. I ended up using a different method rather than asking for an input to achieve the same/similar result. Thanks guys for giving me the possible solutions! I hope they have better references and library for Python!

Sign In or Register to comment.