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
  Pyqt5 - Close a modal window Ninja2112 1 81 5 hours ago
Last Post: Axel_Erfurt
  Transparent window background, but not text on it muzicman0 8 6,906 Feb-13-2025, 06:16 AM
Last Post: elonnmusk
  [PyQt] Popup window not coming RamanSMann 2 809 Jan-02-2025, 02:18 AM
Last Post: lyly19
  [Kivy] Asynchronous operation without window freezing T800 0 682 Dec-06-2024, 05:40 AM
Last Post: T800
  [Tkinter] Modal window DPaul 16 8,974 Nov-05-2024, 04:18 PM
Last Post: kaliumster
  Tkinter multiple windows in the same window hosierycouch 1 1,223 May-30-2024, 04:28 AM
Last Post: deanhystad
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 2,517 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  ValueError: could not convert string to float: '' fron Entry Widget russellm44 5 4,411 Mar-06-2024, 08:42 PM
Last Post: russellm44
  [Tkinter] CTkScrollableDropdown error: bad window path name ".!ctkscrollabledropdown" CopperGenie 1 1,659 Mar-03-2024, 04:32 AM
Last Post: deanhystad
  [Tkinter] (CLOSED) CTkScrollableDropdown error: bad window path name ".!ctkscrollabledropdown" CopperGenie 4 2,503 Mar-03-2024, 03:21 AM
Last Post: CopperGenie

Forum Jump:

User Panel Messages

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