If I make an entry box on a window, then change the coordinates, the box stays put like I want. Now is there a way to set new text in that box after the coordinate change? I can't figure it out for my code

I do not understand what you mean:

import Tkinter as tk

def entry_down(event):
    frame.forget()
    frame.pack()
    entry.forget()
    entry.pack()
    entry.bind('<Return>', entry_up)
    print('Value: %s, from top to down' % entry.get())
    
def entry_up(event):
    frame.forget()
    frame.pack(side=tk.TOP)
    entry.bind('<Return>', entry_down)
    print('Value: %s, from down to top' % entry.get())

root = tk.Tk()
frame = tk.Frame(root, bg= 'yellow', width=300, height=200)
frame.pack()

entry = tk.Entry(root)
entry.pack()
entry.bind('<Return>', entry_up)
#entry has not setText method but insert like text widgets
entry.insert(tk.AtEnd(), 'Hi!')
root.mainloop()

Edited 5 Years Ago by pyTony: n/a

Here less misleading version of above code, with unnecessary stuff cleaned out.

import Tkinter as tk

def entry_down(event):
    entry.forget()
    entry.pack()
    entry.bind('<Return>', entry_up)
    entry.insert(tk.AtEnd(), 'Down! ')
    
def entry_up(event):
    frame.forget()
    frame.pack()
    entry.bind('<Return>', entry_down)
    entry.insert(tk.AtEnd(), 'Up ! ')

root = tk.Tk()
frame = tk.Frame(root, bg= 'yellow', width=300, height=200)
frame.pack()

entry = tk.Entry(root)
entry.pack()
entry.focus()
entry.bind('<Return>', entry_up)
#entry has not setText method but insert like Text widgets
entry.insert(tk.AtEnd(), 'Hi! ')
root.mainloop()

Edited 5 Years Ago by pyTony: focus()

Thanks for the help, but I think I got it. I have to create an entry box on a graphics window before changing the coordinates of the window itself, its for a class project

This article has been dead for over six months. Start a new discussion instead.