Python Forum
Transfer Toplevel window entry to root window entry with TKinter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transfer Toplevel window entry to root window entry with TKinter
#1
With Tkinter, on a PopUp Toplevel window with an Entry and Button, when Destroy by the button, I want the TopLevel window Entry to be transferred to my root window entry. The code below transfer the root window entry value to the popup window entry. If the entry of the popup window is changed, how to transfer it to the root window entry?

  1. from tkinter import *
    root = Tk()
    root.geometry("250x100")
    root.title("Root Window")
    
    
    def open_popup(num):
    popup = Toplevel()
    popup.title("PopUp")
    popup.geometry("250x100")
    
    value = Entry(popup)
    value.place(height=25, width=25, x=100, y=10)
    value.insert(0, str(num))
    
    btn_ok = Button(popup, text="Return", command=popup.destroy)
    btn_ok.place(height=30, width=60, x=90, y=45)
    
    
    main_entry = Entry(root)
    main_entry.place(height=25, width=30, x=110, y=10)
    main_entry.insert(0, "111")
    
    button_ok = Button(
    root, text="OK", command=lambda: open_popup(main_entry.get()))
    button_ok.place(height=30, width=30, x=110, y=45)
    
    root.mainloop()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] Need help positioning Entry() fields LarryJ 2 84 Mar-26-2026, 08:58 PM
Last Post: deanhystad
  PyQt5 - Get a parameter from a modal window Ninja2112 5 751 Nov-24-2025, 02:18 PM
Last Post: deanhystad
  [Tkinter] passing value from tkinter entry to create xml document iqbshaik 7 3,569 Aug-28-2025, 10:32 AM
Last Post: david568
  Trying to access a method from my Toplevel Form avmvldr 1 1,015 Jul-09-2025, 11:59 PM
Last Post: deanhystad
  Pyqt5 - Close a modal window Ninja2112 9 2,842 Apr-23-2025, 02:56 PM
Last Post: deanhystad
  [PyQt] Popup window not coming RamanSMann 2 1,549 Jan-02-2025, 02:18 AM
Last Post: lyly19
  [Kivy] Asynchronous operation without window freezing T800 0 1,349 Dec-06-2024, 05:40 AM
Last Post: T800
  [Tkinter] Modal window DPaul 16 14,370 Nov-05-2024, 04:18 PM
Last Post: kaliumster
  Tkinter multiple windows in the same window hosierycouch 1 2,005 May-30-2024, 04:28 AM
Last Post: deanhystad
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 4,032 Mar-17-2024, 09:37 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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