This seems like it should be incredibly easy to do, but I'm struggling. Programming is not my main background, so I'm lacking a lot of the basics, but I'm trying to learn.
The issue I'm dealing with is I want to use a Tkinter button to display a list of buttons (currently only one), and when one of those buttons is pressed, it inputs the text from said button into a string variable, closes the button window, and continues on with the code.
Here's what I've got for this section:
root = tk.Tk()
def data(name):
global query
query = name
B = tk.Button(root, text ='LogID', command = data('LogID'))
B.pack()
root.mainloop()
print query
If this seems perhaps a little jumbled or slapdash, it's because it is.
There's code before, and code after this section. I'd like the window to close (root.destroy()) when the button is pressed and for the code to print the text from 'query' so I know it's passed the value to it.
When I run it, it hangs on the root.mainloop() section, or seems to. And I'll be honest, I don't fully understand what that does in the code, all I know is it needs it.