Is there any way to add tooltips to the individual entries of a combobox? I'd like it so that when the combobox is open (and only when it is open) and the user mouses over one of the possible selections, additional information would show up in a tooltip.
It seems like there aren't any real widgets within a combobox to add the tooltips to. Is the only way to do this to somehow put widgets (like labels) in the entries of the combobox?
I think you are on the right track with putting labels in the combobox and adding tooltips to the labels. You can create a custom list store for the combo box which contains the labels. This is an attempt at it, not in pygtk but in guile-gnome (my native habitat, sorry! I may try a translation to pygtk later) It runs, but not correctly yet, the labels are not being displayed.
Actually, getting the gtkcombobox to display widgets (rather than just text) seems possible but difficult - see here for example. It may require a custom GtkCellRendererWidget class that is not part of the base library.
(use-modules (oop goops)
(gnome gtk))
(define w (make <gtk-window> #:title "combo demo"))
(connect w 'destroy (lambda args (gtk-main-quit)))
(define combo (make <gtk-combo-box>))
(define list-store (gtk-list-store-new `(,<gtk-label>)))
(set combo 'model list-store)
(define tooltips (gtk-tooltips-new))
(define (list-store-append-label-with-tooltip list-store text tip)
(let ((label (make <gtk-label> #:label "hello")))
(gtk-tooltips-set-tip tooltips label tip #f)
(gtk-list-store-set-value
list-store
(gtk-list-store-append list-store)
0
label)))
(list-store-append-label-with-tooltip list-store "hello" "first word")
(list-store-append-label-with-tooltip list-store "world" "second word")
(add w combo)
(show-all w)
(gtk-main)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With