How to update a Tix.ComboBox's text?

By : Moe
Source: Stackoverflow.com
Question!

I have a Tix.ComboBox with an editable text field. How do I force the variable holding the value for the text to update?

Let me give a more concrete explanation. I have a combo box and a button. When I click the button, it pops up a message box with the value of the combo box. Let's say the combo box text field currently has the value "thing1". If I type "new" into the box and then click on the button with my mouse, it will pops up the message "thing1". If I type "new" in the box and then tab focus away from the combo box and then click the button the pop up message says "new".

Ho do I force the combo box to update it's value to new without requiring that I tab away from the combo box?

I have included sample code.

import Tix
import tkMessageBox

class App(object):
    def __init__(self, window):
        window.winfo_toplevel().wm_title("test")
        self.window = window

        self.combo = Tix.ComboBox(window)
        self.combo.insert(Tix.END, 'thing1')
        self.combo.insert(Tix.END, 'thing2')
        self.combo.entry['state'] = "normal"
        self.combo['editable'] = True
        self.combo.pack()

        button = Tix.Button(window)
        button['text'] = "Go"
        button['command'] = self.go
        button.pack()

    def go(self):
        tkMessageBox.showinfo('info', self.combo['value'])


if __name__ == '__main__':
    root = Tix.Tk()
    App(root)
    root.mainloop()
By : Moe


Answers

NOTE: copy of Moe's answer that can be selected as chosen answer

woo! solved it on my own.

Use

self.combo['selection']

instead of

self.combo['value']
By : tzot


This video can help you solving your question :)
By: admin