Adding label to tkinter widget changes entire layout Adding label to tkinter widget changes entire layout tkinter tkinter

Adding label to tkinter widget changes entire layout


The simplest solution is not force the window to a specific size, and to always have that label there. Set the width large enough to include the full text of the message. When you are ready to show the value, use the configure method to show the text.

Here's a complete example based on your code:

from tkinter import *root = Tk()text = Text(root)text.pack(fill="both", expand=True)with open(__file__, "r") as f:    text.insert("end", f.read())                def find_next():    file_end.configure(text='Found 1st occurance from the top, end of file has been reached.')find_window = Toplevel()#find_window.geometry('338x70')find_window.title('Find')Label(find_window, text='Enter text to find:').grid(row=0, column=0, sticky=W)find_text = Entry(find_window, highlightcolor='blue', highlightbackground='blue', highlightthickness=1)find_nextbutton = Button(find_window, text='Find Next', command=find_next)find_allbutton = Button(find_window, text='Find All')file_end = Label(find_window, width=50)find_text.grid(row=0, column=1, sticky=W)find_nextbutton.grid(row=0, column=2, sticky=W)find_allbutton.grid(row=1, column=2, sticky=W)file_end.grid(row=2, columnspan=4, sticky="w")find_window.lift(root)root.mainloop()