Use of postcommand in combobox?

Volker vos at lundinova.se
Wed Jun 27 14:24:11 UTC 2018


Maybe someone is interested in a workaround for the postcommand in 
combobox issue:

(postcommand is a script which will be called right before displaying
the pop-down list of choices. This can be used to more dynamically set
the list of choices, via the values option.
Source: https://tkdocs.com/widgets/combobox.html)

Not really elegant but it solves my problem:

(defun combo-values-when-entering ()
   "Combobox updating values when the mouse enters the widget."
   (ltk:with-ltk ()
     (let* ((f (make-instance 'ltk:frame))
            (outconsole (make-instance 'ltk:scrolled-text :borderwidth 2 
:relief :raised :master f))
            (c (make-instance 'ltk:combobox :master f :text "Values:")))
       (ltk:pack f)
       (ltk:pack outconsole)
       (ltk:pack c :side :left :padx 2)
       (ltk:append-text outconsole "Line 1 (Add more lines here and use 
the combobox widget thereafter)")
       (ltk:bind c "<Enter>"
                 (lambda (evt)
                   (declare (ignore evt))
                   (setf (options c) (cl-ppcre:split #\newline (text 
outconsole))))))))

(The reading from the textwidget is just an example. In my application
I want to read the state of some ports when using the combobox.)

/Volker




More information about the ltk-user mailing list