Python Forum
Set input text from button
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set input text from button
#2
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
Reply


Messages In This Thread
Set input text from button - by gio123 - Feb-28-2018, 03:36 PM
RE: Set input text from button - by gio123 - Mar-01-2018, 10:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't change the colour of Tk button text Pilover 6 14,502 Nov-15-2022, 10:11 PM
Last Post: woooee
  [Tkinter] Make my button text update? Skata100 1 2,013 Aug-07-2021, 05:37 AM
Last Post: deanhystad
  Updating button text based upon different variable values knoxvilles_joker 0 2,211 Apr-18-2021, 04:13 AM
Last Post: knoxvilles_joker
  tkinter | Button color text on Click Maryan 2 3,316 Oct-09-2020, 08:56 PM
Last Post: Maryan
  How to make button text bold in Tkinter? scratchmyhead 2 11,906 May-16-2020, 02:53 AM
Last Post: scratchmyhead
  [Tkinter] Text Button - How Do I Reduce The Margin? vman44 6 11,037 Apr-27-2020, 10:48 PM
Last Post: Larz60+
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 13,667 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 4,949 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  Text after push button chano 13 5,239 Jul-05-2019, 03:10 PM
Last Post: Yoriz
  [Tkinter] how to input a random entry with each button press? nadavrock 1 6,331 Jun-17-2019, 05:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020