# Get User Input and Save It

**URL:** https://discourse.processing.org/t/get-user-input-and-save-it/22935
**Category:** Coding Questions
**Tags:** homework
**Created:** [July 30, 2020, 8:08pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935 "2020-07-30T20:08:27Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 30, 2020, 8:08pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/1 "2020-07-30T20:08:27Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [July 30, 2020, 9:16pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/2 "2020-07-30T21:16:09Z")

</div>

There are several GUI libraries listed on the Processing website: [https://processing.org/reference/libraries/#gui](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](https://tabreturn.github.io/code/processing/python/2019/03/19/processing.py_in_ten_lessons-7.5-_controlp5.html)), 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.).

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 30, 2020, 9:23pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/3 "2020-07-30T21:23:59Z")

</div>

> [@greenArtist7](#):
>
> examples of apps that were created using processing, I would love to see them to get some inspiration.

> [@Some Movies I made](https://discourse.processing.org/t/some-movies-i-made/13306):
>
> Hello, I made a few movies using processing. A toast to hamoid and his great lib. Is somebody is interested in the code, tell me. Regards, Chrisir

Warm regards

Chrisir

---

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 30, 2020, 9:36pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/4 "2020-07-30T21:36:51Z")

</div>

Thank you for sharing! These are great!

---

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 30, 2020, 9:39pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/5 "2020-07-30T21:39:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [July 30, 2020, 9:50pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/6 "2020-07-30T21:50:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 30, 2020, 10:06pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/7 "2020-07-30T22:06:13Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [July 30, 2020, 10:32pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/8 "2020-07-30T22:32:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 30, 2020, 11:06pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/9 "2020-07-30T23:06:34Z")

</div>

Thank you very much!

---

<div class="post-metadata">

### Author: ![qewer3322](https://avatars.discourse-cdn.com/v4/letter/q/e19adc/32.png) [@qewer3322](https://discourse.processing.org/u/qewer3322)
#### Post date: [July 31, 2020, 8:05am UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/10 "2020-07-31T08:05:05Z")

</div>

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

```auto
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.

> [@greenArtist7](#):
>
> Also, if anyone has any examples of apps that were created using processing, I would love to see them to get some inspiration.

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)  
[https://qewer33.itch.io/the-grave-pixelart-tool](https://qewer33.itch.io/the-grave-pixelart-tool)

---

<div class="post-metadata">

### Author: ![greenArtist7](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@greenArtist7](https://discourse.processing.org/u/greenArtist7)
#### Post date: [July 31, 2020, 5:13pm UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/11 "2020-07-31T17:13:21Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [August 2, 2020, 11:10am UTC](https://discourse.processing.org/t/get-user-input-and-save-it/22935/12 "2020-08-02T11:10:53Z")

</div>

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

Also see [Places online where documentation of amazing projects exist](https://discourse.processing.org/t/places-online-where-documentation-of-amazing-projects-exist/3601)
