It should be very simple, but I'm really trying to fix it. All I need is a simple ttk ComboBox that updates the variable when the selection changes.
In the example below, I need the value_of_combo variable to value_of_combo updated automatically every time a new choice is made.
from Tkinter import * import ttk class App: value_of_combo = 'X' def __init__(self, parent): self.parent = parent self.combo() def combo(self): self.box_value = StringVar() self.box = ttk.Combobox(self.parent, textvariable=self.box_value) self.box['values'] = ('X', 'Y', 'Z') self.box.current(0) self.box.grid(column=0, row=0) if __name__ == '__main__': root = Tk() app = App(root) root.mainloop()
python tkinter ttk
bhaskarc
source share