0

Is there a way that just by changing the element in the combobox triggers a check being sent to see what the change was and then to get the text? I want to do this without clicking a button to execute a function to find the text, i want it to be done automatically, without me using a button to check it.

Edit: So i found that i have to use trace, although when using it in an example i found documented on someone elses help post it doesnt work for me, instead it returns this error: TypeError: add_store_options_ys() takes 1 positional argument but 3 were given

here is my code, if anyone can help that would be great.

rows = 0
while rows < 50:
    root.rowconfigure(rows, weight=1)
    root.columnconfigure(rows, weight=1)
    rows += 1
nb = ttk.Notebook(root)
nb.grid(row=1, column=0, columnspan=50, rowspan=49, sticky='NESW')

page1 = ttk.Frame(nb, style='body.TFrame')
nb.add(page1, text='Create Tasks')

specify = StringVar()

site_lbl = Label(page1, text="Site", bg='#1C2833', fg='#FDFEFE', font=("Helvetica", 14))
site_lbl.place(x=5, y=20)
site_combo = ttk.Combobox(page1, textvariable=specify, width=15, values=[
    'YeezySupply'
])
site_combo.place(x=55, y=25)


def add_store_options_ys(self):
    if self.specify.get() == 'YeezySupply':
        store_ys()


def store_ys():
    stylecode_lbl = Label(page1, text="Site", bg='#1C2833', fg='#FDFEFE', font=("Helvetica", 14))
    stylecode_lbl.place(x=5, y=20)
    stylecode_entry = Entry(page1, width=15, bg='#1C2833', fg='#FDFEFE', font=("Helvetica", 8))
    stylecode_entry.place(x=55, y=25)


specify.trace_variable("w", add_store_options_ys)
  • Does this answer your question? [Trace Variable - ComboBox Tkinter](https://stackoverflow.com/questions/40939934/trace-variable-combobox-tkinter). Relevant [what-are-the-arguments-to-tkinter-variable-trace-method-callbacks](https://stackoverflow.com/questions/29690463/what-are-the-arguments-to-tkinter-variable-trace-method-callbacks) – stovfl Jan 07 '20 at 18:43
  • The combobox is documented to emit an event when it has changed. Have you tried using that? – Bryan Oakley Jan 07 '20 at 19:01

0 Answers0