I want to have UI where when I press a button, stuff pops up in the console. The issue is the stuff prints into the console before I press the button. After some testing, I have found that if I don't use parenthesis to call my function in the command argument, it works fine.
ex: A function called hello prints hello world in the console, so I would call it like button=Button(master, command=hello) instead of button=Button(master, command=hello())
The issue with this way is I can't use parameters.
here is an example of a code similar to mine:
index={'Food':['apple', 'orange'], 'Drink':['juice', 'water', 'soda']}
Names=['Food', 'Drink']
def display(list):
for item in list:
print(item)
from tkinter import *
mon=Tk()
app=Frame(mon)
app.grid()
for item in Names:
button=Button(mon, text=item, command=diplay(index[item]))
button.grid()
mon.mainloop()
Any ideas of how to be able to use parameters? I hope this all made sense, but if it didn't please leave a comment. Thank You.