GUI - problem with delete-child

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

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:

#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:

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

Alex.

4 Likes