# Redraw/Remove Gui

**URL:** <https://forum.renoise.com/t/redraw-remove-gui/29919>\
**Category:** Renoise Tool Development\
**Created:** [September 19, 2010, 12:47am UTC](https://forum.renoise.com/t/redraw-remove-gui/29919 "2010-09-19T00:47:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cie](https://forum.renoise.com/user_avatar/forum.renoise.com/cie/32/71_2.png) [@Cie](https://forum.renoise.com/u/Cie)\
**Post date:** [September 19, 2010, 12:47am UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/1 "2010-09-19T00:47:03Z")

</div>

Hello,

on a certain event, I would like to redraw my GUI. To build up a gui I use:

```auto
vb = renoise.ViewBuilder()   
.. fill with buttons etc..  

```

How to destroy/remove this vb?  
With again declaring vb in the same way, a second gui popups, but the old gui stays. Also vb = nil does not have any effect.

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [September 20, 2010, 7:42am UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/2 "2010-09-20T07:42:16Z")

</div>

A vb only creates new GUI elements. If you want to remove previously added view components, you can do so via:  
my\_view:remove\_child(some\_child\_view)

See [https://code.google.com/p/xrnx/source/browse/trunk/Documentation](https://code.google.com/p/xrnx/source/browse/trunk/Documentation) -\> Renoise.ViewBuilder.API.lua for more info

---

<div class="post-metadata">

**Author:** ![Cie](https://forum.renoise.com/user_avatar/forum.renoise.com/cie/32/71_2.png) [@Cie](https://forum.renoise.com/u/Cie)\
**Post date:** [September 20, 2010, 2:52pm UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/3 "2010-09-20T14:52:38Z")

</div>

> [@taktik](#):
>
> A vb only creates new GUI elements. If you want to remove previously added view components, you can do so via:  
> my\_view:remove\_child(some\_child\_view)
> 
> See [GitHub - renoise/xrnx: The official Renoise Lua Scripting repository](https://code.google.com/p/xrnx/source/browse/trunk/Documentation) → Renoise.ViewBuilder.API.lua for more info

Thanks. Then there would be a my\_view:remove\_all\_childs very helpful.  
You either can not remove an former created dialog, can you?

```auto
app():show_custom_dialog  

```

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [September 20, 2010, 3:07pm UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/4 "2010-09-20T15:07:23Z")

</div>

To remove all views with a single “remove\_child” call, add all your views into one “big” parent view. Like for example a row, column. Then you only need to remove this row or rack to get rid of everything…

---

<div class="post-metadata">

**Author:** ![Cie](https://forum.renoise.com/user_avatar/forum.renoise.com/cie/32/71_2.png) [@Cie](https://forum.renoise.com/u/Cie)\
**Post date:** [October 8, 2010, 6:02pm UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/5 "2010-10-08T18:02:58Z")

</div>

Thank you.

But when putting my views into one big parent view, I got an error, when recreating/adding the previously removed view again:

```auto
*** std::logic_error: 'ViewBuilder: a view with the id 'track_number1' was already registered to this viewbuilder instance.'  
*** stack traceback:  

```

The child view I added to the parent view has the id “track\_number”…i

```auto
  
 local track_number = vb:popup {  
 id = 'track_number'..i,  
 bind = tracks[i].track_number,  
 value = tracks[i].track_number.value,  
 width = 80,  
 items = track_names  
 }  
 lights_rows[i]:add_child(track_number)  
...  
  

```

Do I have to remove explicit all views with a certain id? (Removing a parent view does not automatically remove all id’s of the child views?)

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [October 11, 2010, 10:33am UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/6 "2010-10-11T10:33:30Z")

</div>

Cie: Could you let us know what exactly you need/want to do? Its about recreating or updating the step sequencer GUI, isn’t it? What do you want to do there? I think it makes more sense to find a solution for this special case, your tool.

Re: ‘ViewBuilder: a view with the id ‘track\_number1’ was already registered to this viewbuilder instance.’

You can use as many “ViewBuilder”'s you need or want. Even multiple ones per GUI, dialog. They only hold view IDs in a table, you can later on access and do the construction of views.

If you anyway have locals of your views, like here:  
local track\_number = vb:popup {  
id = ‘track\_number’…i  
}

then you don’t need an ID at all, and could collect, memorize the view object directly in a table.

But as said above: Let us know what exactly you need to do in your tool, and lets try to find a solution for exactly this problem instead.

---

<div class="post-metadata">

**Author:** ![Cie](https://forum.renoise.com/user_avatar/forum.renoise.com/cie/32/71_2.png) [@Cie](https://forum.renoise.com/u/Cie)\
**Post date:** [November 1, 2010, 10:40pm UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/7 "2010-11-01T22:40:50Z")

</div>

Thank you Taktik for your will to help, it is really appreciated. ![:)](https://files.renoise.com/forum/emoticons/default/smile.gif)  
Sorry for the late reply, unfortunately I had the last weeks no time due to work.

Yes this question refers to the StepSequencer. What I would like to do in my GUI is to add/remove dynamically a row of steps (that represents a track), if the user adds/removes a track. So when the Sequencer Gui is visible, and the user removes a track or adds one, a new row of steps becomes visible or gets removed.  
As there is no possibility to check which track-number exactly was removed (only in general, that the amount of tracks has changed is observable), I had the idea to remove all rows of steps from the gui, parse all tracks, and add for each track a row again. Unfortunately I use IDs for each row to adress them from anywhere within the application; and when recreating the rows (with the same IDs) there is an error not to use the same ID again. At this point I got stuck.  
If the gui is closed completely after a new track is added/removed, and then reloaded through clicking on the menue entry, it works well. Unfortunately I do not know how to close and restart the gui with a lua command.  
If you know a way how to solve this problem, it would be great. Thank you anyway for your effort and your help.

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [November 1, 2010, 11:14pm UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/8 "2010-11-01T23:14:29Z")

</div>

> [@Cie](#):
>
> As there is no possibility to check which track-number exactly was removed (only in general, that the amount of tracks has changed is observable)

Info about what exactly happened to the tracks (or patterns, instruments and so on list) is passed as “notification” argument to the notifier:  
See [GitHub - renoise/xrnx: The official Renoise Lua Scripting repository](https://code.google.com/p/xrnx/source/browse/trunk/Documentation/Renoise.Document.API.lua#380) for more info please.

For a removed track you will get the following argument passed to your notifier: {  
type = “remove”,  
index = track\_index which got removed  
}

* * *

If the view builder IDs are then still in your way, then use a builder per track you are showing, or clear old IDs before assigning new ones:  
vb.views[“some\_view”] = nil – then create new views with the same id and same view builder

---

<div class="post-metadata">

**Author:** ![Cie](https://forum.renoise.com/user_avatar/forum.renoise.com/cie/32/71_2.png) [@Cie](https://forum.renoise.com/u/Cie)\
**Post date:** [November 26, 2010, 1:38am UTC](https://forum.renoise.com/t/redraw-remove-gui/29919/9 "2010-11-26T01:38:51Z")

</div>

> [@taktik](#):
>
> If the view builder IDs are then still in your way, then use a builder per track you are showing, or clear old IDs before assigning new ones:  
> vb.views[“some\_view”] = nil – then create new views with the same id and same view builder

Thank you very much, that solved my gui update problem.
