Get User Input and Save It

Hello,

I need to create an app using processing for a homework assignment. I’m thinking about an app that requires the user to input text information, and use that to randomize a selection. What would be the best way for me to get and save the user input? Is there a library that will help with this?

Also, if anyone has any examples of apps that were created using processing, I would love to see them to get some inspiration.

TIA!

There are several GUI libraries listed on the Processing website: https://processing.org/reference/libraries/#gui

Most will include examples (File > Examples, in the Processing IDE) if you install them.

I’ve used ControlP5 in Python Mode (example), which I can report works nicely.

If you need to store the user data so that it persists (between each run), you’ll have to write to a text file or some other external file format (database, etc.).

2 Likes

Warm regards

Chrisir

2 Likes

Thank you for sharing! These are great!

1 Like

Thank you. What I’m trying to do is have the program retain the information for one “run”. For example, the user would put in different colors at the beginning, and then the program will run to select one of the colors randomly. Would the ControlP5 library be a good use for that? Tried reading through what each of the libraries does, but it was a bit confusing for me.

ControlP5 will provide widgets to capture user input – things like text fields, checkboxes, buttons, and so on.

How would “the user put in different colors”? Type them in? Select them from drop-down lists? If it’s something like sampling from a color palette, a GUI library might not be necessary.

1 Like

It would be typed in by the user. I’m will be requiring different data, but it will be typed in. Would the ControlP5 library be the best for that? To read the typed in data, and retain it, for one full run of the program?

Yes, ControlP5 (and a few other GUI libraries) will provide text fields for capturing whatever the user might type in. That data is stored in attributes you can use throughout your program.

1 Like

Thank you very much!

1 Like

If you want, you can also do it without a library. This code by Chrisir worked pretty good for me:

boolean text = true;
String export = "";

void keyPressed() {
  //name typing
  if (text == true && key==BACKSPACE) {
    if (export.length()>0) {
      export=export.substring(0, export.length()-1);
    }
  } else if (text == true) {
    export+=key;
  }
}

And then display the string with text(); . A gui library would probably be a bit cleaner tho.

It is nothing much considering I’m also pretty new to this community but you can take a look at my simple pixelart tool made with processing. It also includes the source code and it has some text input stuff, might help:
(I used the uibooster gui library in this for file selection)

1 Like

Thank you for sharing this. Your simple pixel art tool look amazing!

1 Like

Here is a section Gallery in the forum where you find lots of examples

Also see Places online where documentation of amazing projects exist