def my_child():
my_w_child=tk.Toplevel(my_w)
my_w_child.geometry("400x200")
my_w_child.title('www.plus2net.com')
l1_q=tk.Label(my_w_child,text='Query')
l1_q.grid(row=1,column=1)
t1_child=tk.Text(my_w_child, bg='yellow',height=5,width=45)
t1_child.grid(row=2,column=1,padx=10,columnspan=2)
t1_child.insert(tk.END, sql_str.get()) # to retain the query while opening
b3=tk.Button(my_w_child,text='Submit', command=lambda:child_close())
b3.grid(row=3,column=1)
def child_close():
sql_str.set(t1_child.get("1.0",'end-1c')) # collect the query
my_data(t1_child.get("1.0",'end-1c')) # pass the query
my_w_child.destroy() # close the child window
On click of submit button on child window, we will execute another function child_close() to close the child window and pass the user entered query to another function my_data(). After sending the data we will close the child window.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.