Set input text from button - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Set input text from button (/thread-8616.html) |
Set input text from button - gio123 - Feb-28-2018 Hi All, I need to get the text of the textbox (ScrolledText) by pressing the "Find" button. At the moment the command print the text entered but I need to set a variable that contains this text. This is the Python code from tkinter import * from tkinter.scrolledtext import ScrolledText mainwin = Tk() Label(mainwin, text="Title").grid(row=0, column=1) Label(mainwin, text="Insert description").grid(row=1, column=0) st = ScrolledText(mainwin, height=5); st.grid(row=1, column=1) Button(mainwin, text="Find", command=(lambda: print(st.get(1.0, END)))).grid(row=1, column=2, sticky="EW") Label(mainwin, text="Watson Answer:").grid(row=2, column=0) Button(mainwin, text="Exit", command=sys.exit).grid(row=3, column=0, columnspan=3, sticky="EW") mainwin.mainloop() Any help will be greatly appreciated. Thanks in advance for your kind support. Regards, Giovanni RE: Set input text from button - gio123 - Mar-01-2018 Hi All, I need to get the text of the textbox (ScrolledText) by pressing the "Find" button. At the moment the command prints the text entered but I need to set a global variable that contains this text. This is the Python code from tkinter import * from tkinter.scrolledtext import ScrolledText mainwin = Tk() Label(mainwin, text="Title").grid(row=0, column=1) Label(mainwin, text="Insert description").grid(row=1, column=0) st = ScrolledText(mainwin, height=5); st.grid(row=1, column=1) Button(mainwin, text="Find", command=(lambda: print(st.get(1.0, END)))).grid(row=1, column=2, sticky="EW") Label(mainwin, text="Watson Answer:").grid(row=2, column=0) Button(mainwin, text="Exit", command=sys.exit).grid(row=3, column=0, columnspan=3, sticky="EW") mainwin.mainloop()Any help will be greatly appreciated. Thanks in advance for your kind support. Regards, Giovanni |