# GUI - problem with delete-child

**URL:** <https://racket.discourse.group/t/gui-problem-with-delete-child/1160>\
**Category:** Questions & Answers\
**Tags:** gui\
**Created:** [July 19, 2022, 5:54pm UTC](https://racket.discourse.group/t/gui-problem-with-delete-child/1160 "2022-07-19T17:54:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![alexh](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/alexh/32/315_2.png) [@alexh](https://racket.discourse.group/u/alexh)\
**Post date:** [July 21, 2022, 9:49am UTC](https://racket.discourse.group/t/gui-problem-with-delete-child/1160/5 "2022-07-21T09:49:26Z")

</div>

The qresults list does contain a `vertical-pane%` as the container for the widget:

> <https://github.com/alex-hhh/qresults-list/blob/b680a09a8e83cc72fb306e3d9a8ebaff91a7040d/private/qresults-list.rkt#L362>

`pane%` objects cannot be deleted from their parent container. Note that "deleting" an object from a container (such as a `frame%`) does not actually destroy the object, it just sets its style to `'deleted` and makes it hidden. This operation is not valid for `pane%` and classes derived from `pane%` so they cannot be deleted from their parent container. All other objects however can be deleted.

As a workaround, I would recommend adding an intermediate `vertical-panel%` object to the frame and add the `qresults-list%` to it. You should than be able to delete the panel. Following your example in your original post, this would be:

```scheme
#lang racket
(require racket/gui)

(define frame (new frame% [label "My Frame"]))

(define my-panel (new vertical-panel% [parent frame]))
(define my-pane (new vertical-pane% [parent my-panel]))

(send frame show #t)

(for ([this-child (send frame get-children)])
(send frame delete-child this-child))

```

Finally, deleting child widgets one by one will trigger layout re-calculations which cause visible flickering. I would recommend either wrapping the for loop with the `delete-child` inside a `begin-container-sequence` /`end-container-sequence`, or using `change-children`, like so:

```scheme
(send frame change-children (lambda (previous-children) null))

```

Alex.

---

_[View the full topic](https://racket.discourse.group/t/gui-problem-with-delete-child/1160)._
