Delete/Replace widget with fresh instance

Ryan pixeloutlaw at gmail.com
Tue Jun 16 03:25:43 UTC 2020


Hello,

I've managed to get what I *think* is correct.
Really the CLOS side should track CLOS child objects when placed, 
gridded, and packed so it can be done without TCL.

(defun tk-parent (w)
   "Returns a Wish understood representation of the CLOS object parent"
   (let* ((old-path (widget-path w))
          (parent-path (subseq old-path 0 (search "." old-path :from-end 
t))))
     parent-path))

(defun tk-destroy-widget (w)
   "Given a CLOS object destroys it on the Wish side"
   (send-wish (concatenate 'string "destroy " (widget-path w)))
   (setf w NIL))

(defun tk-destroy-children (w)
   "Given a CLOS object destroys the children on the Wish side"
   (let ((command-string
          "foreach w [winfo children \"~a\"] { destroy $w }"))
     (send-wish (format nil command-string (widget-path w)))))


On 6/13/20 3:20 PM, Ryan wrote:
> Good Afternoon All,
>
> First thanks for a great way to make simple GUIs in Common Lisp.
> In my current application I have a tray of buttons.
> This currently gets populated from a directory path defined by the user.
> I keep this frame as a special variable in Common Lisp so I can easily 
> access it across all functions.
>
> Is there a way to get the parent of a widget currently?
> How about a list of all children?
>
> I'd like to write a function that saves the frame's parent, deletes 
> the frame on CL and Tcl sides, then binds and packs a new frame 
> instance in it's place.
>
> Here is a picture of my little launcher program.
>
> https://i.imgur.com/GiOaez7.png
>
>
> You can see how the frame exists inside a notebook and contains buttons.
> Thanks for any help!



More information about the ltk-user mailing list