# Refresh values in P5.gui

**URL:** <https://discourse.processing.org/t/refresh-values-in-p5-gui/27581>\
**Category:** Libraries\
**Created:** [February 4, 2021, 9:43am UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581 "2021-02-04T09:43:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbanks](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rbanks/32/10941_2.png) [@rbanks](https://discourse.processing.org/u/rbanks)\
**Post date:** [February 4, 2021, 9:43am UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581/1 "2021-02-04T09:43:37Z")

</div>

I’m using p5.gui to play with some variables and setting for my sketch. I want to change those variables both in the gui and in code. If I change the variables in code the p5.gui interface doesn’t update automatically to show the new value, so it ends up out of sync with the actual sketch.

Is there a way to force a refresh of the values shown in the gui so they are up to date?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 4, 2021, 10:20am UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581/2 "2021-02-04T10:20:42Z")

</div>

> [@rbanks](#):
>
> Is there a way to force a refresh of the values shown in the gui so they are up to date?

Never tested but given p5.gui is a wrapper for the dat.GUI lib you can look up its API from this link:

> <https://github.com/dataarts/dat.gui/blob/master/API.md>

Methods **listen()** & **updateDisplay()** from class Controller seem more likely to do what you seek.

---

<div class="post-metadata">

**Author:** ![myCatIsAwesome](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@myCatIsAwesome](https://discourse.processing.org/u/myCatIsAwesome)\
**Post date:** [February 4, 2021, 5:11pm UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581/3 "2021-02-04T17:11:12Z")

</div>

A noob in processing myself but for stuff like that in general in coding you have to update the variable AND the ui control where ever you update your variable(or whatever you are changing). I think this is uicontrolx.setValue(…) or something.  
If you want it automatically you can always write a function that is being called in your draw loop if a certain event is true or whatever.

---

<div class="post-metadata">

**Author:** ![rbanks](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rbanks/32/10941_2.png) [@rbanks](https://discourse.processing.org/u/rbanks)\
**Post date:** [February 5, 2021, 12:22pm UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581/4 "2021-02-05T12:22:10Z")

</div>

Thanks, @GoToLoop. You pointed me in the right direction. p5.gui is also based on quicksettings, which is its prototype. Looking in quicksetting.js, I found setValue, mentioned by @myCatIsAwesome. This seemed to work:

```auto
    gui.prototype.setValue(title, value);

```

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [February 15, 2022, 7:21pm UTC](https://discourse.processing.org/t/refresh-values-in-p5-gui/27581/5 "2022-02-15T19:21:00Z")

</div>

@rbanks

Did you succeed with ‘dat.gui’ with P5?
