import tkinter as tk
my_w = tk.Tk()
from tkinter import *
my_w.geometry("250x150")
my_w.title("plus2net.com") # Adding a title
l1 = tk.Label(my_w, text='First' ) # added one Label
l1.grid(row=1,column=1)
e1_str=tk.StringVar()
e1 = tk.Entry(my_w,textvariable=e1_str) # added one Entry box
e1.grid(row=1,column=2)
l2 = tk.Label(my_w, text='Second' ) # added one Label
l2.grid(row=2,column=1)
e2_str=tk.StringVar()
e2 = tk.Entry(my_w,textvariable=e2_str) # added one Entry box
e2.grid(row=2,column=2)
b1 = tk.Button(my_w, text='Update', width=8,
command=lambda: my_upd())
b1.grid(row=3,column=1)
b2 = tk.Button(my_w, text='Reset', width=8,
command=lambda: my_reset())
b2.grid(row=3,column=2)
## buttons for changing font colour of Entries
b3 = tk.Button(my_w, text='fg=green', width=8,
command=lambda: my_config('fg','green'))
b3.grid(row=4,column=1)
b4 = tk.Button(my_w, text='fg=red', width=8,
command=lambda: my_config('fg','red'))
b4.grid(row=4,column=2)
b5 = tk.Button(my_w, text='bg=yellow', width=8,
command=lambda: my_config('bg','yellow'))
b5.grid(row=5,column=1)
b6 = tk.Button(my_w, text='bg=blue', width=8,
command=lambda: my_config('bg','blue'))
b6.grid(row=5,column=2)
def my_upd():
e2_str.set(e1.get()) # read and assign text to StringVar()
def my_reset():
e1.delete(0,END) # Delete first Entry
e2.delete(0,END) # Delete Second Entry
e1.config(bg='#ffffff',fg='#000000') # reset background
e2.config(bg='#ffffff',fg='#000000') # reset background
def my_config(type,col):
if type=='fg':
e1.config(fg=col)
e2.config(fg=col)
elif type=='bg':
e1.config(bg=col)
e2.config(bg=col)
my_w.mainloop()