Bottom Page

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()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] How to add multiple frames to main window Dandy_Don 6 94 Apr-07-2020, 07:39 PM
Last Post: Dandy_Don
  [Tkinter] entry filed sum leveex 4 132 Apr-05-2020, 05:24 PM
Last Post: leveex
  [PyQt] Drag and Move window from menubar WBPYTHON 3 64 Apr-03-2020, 06:15 PM
Last Post: deanhystad
  Problem with setting variable within a Entry validatecommand kenwatts275 1 74 Mar-31-2020, 01:53 AM
Last Post: deanhystad
  [PyQt] Matplotlib figure not showing cursor coordinates in the figure window mart79 0 68 Mar-26-2020, 01:48 PM
Last Post: mart79
  Grid data entry problem kenwatts275 3 117 Mar-22-2020, 03:13 PM
Last Post: kenwatts275
  POPUP on widget Entry taratata2020 4 423 Mar-10-2020, 05:04 PM
Last Post: taratata2020
  Entry Widget issue PA3040 13 298 Mar-06-2020, 10:24 AM
Last Post: Larz60+
  Second Window can't open due to iExit function Jionni 4 160 Feb-29-2020, 06:06 PM
Last Post: Jionni
  Using Tkinter widgets on child window chewy1418 8 413 Feb-27-2020, 10:34 PM
Last Post: Marbelous

Forum Jump:


Users browsing this thread: 1 Guest(s)