21
loading...
This website collects cookies to deliver better user experience
button=tk.Button(form,text="Press Me",command=cmd)
import tkinter as tk
form=tk.Tk()
form.title("Example of Entry widget")
form.geometry('400x200')
button=tk.Button(form,text="Press Me")
button.pack()
form.mainloop()
show()
import tkinter as tk
form=tk.Tk()
form.title("Example of Entry widget")
form.geometry('400x200')
a=tk.IntVar()
def count():
a.set(a.get()+1)
button.config(text=str(a.get()))#don't forget the str()
button=tk.Button(form,text="Press Me",command=count)
button.pack()
form.mainloop()
show()
entry = tk.Entry(parent)
import tkinter as tk
form=tk.Tk()
form.title("Example of Entry widget")
form.geometry('400x200')
TB1=tk.Entry(form,width = 20)
TB1.pack()
form.mainloop()
show()
get()
function. The below example will make things very clear.import tkinter as tk
form=tk.Tk()
form.title("Example of Entry widget")
form.geometry('400x200')
TB1=tk.Entry(form,width = 20)
TB1.pack()
def show():
button.config(text=TB1.get())
'''
The TB1.get() method returns the string value of the text inputted into the entry widget. By using the config() method of the button, we can set the text of the button.
'''
button=tk.Button(form,text="", command=show)
button.pack()
form.mainloop()
show()
import tkinter as tk
form=tk.Tk()
form.title("Example of textbox widget")
form.geometry('400x200')
TB1=tk.Text(form,width = 20)
TB1.pack()
form.mainloop()
show()
import tkinter as tk
form=tk.Tk()
form.title("Example of textbox widget")
form.geometry('400x200')
TB1=tk.Text(form,width = 5,height = 5)
TB1.pack()
form.mainloop()
show()
text=TB1.get(1.0, "end-1c")
will give the entire result.import tkinter as tk
form=tk.Tk()
form.title("Example of Entry widget")
form.geometry('400x200')
TB1=tk.Text(form,width = 7,height=5)
TB1.pack()
def show():
button.config(text=TB1.get(1.0, "end-1c"))
'''
get(start, [end])
where,
start is starting index of required text in TextBox,
end is ending index of required text in TextBox
'''
button=tk.Button(form,text="", command=show)
button.pack()
form.mainloop()
show()