0

How can I make absolute placement from right? This is a piece of code I use:

# search textbox + search button
search_box = customtkinter.CTkEntry(master=root, placeholder_text="CTkEntry")
search_box.place(height=25, width=300, y=12.5, x=400, anchor =tkinter.NE )

search_button= customtkinter.CTkButton(master=root, text="search", command=place_flag)
search_button.place(height=25, width=75, y=12.5, x=900, anchor=tkinter.NE)

root.mainloop()

This is my output:

tkinter app

I want to place search_box and search_button against each other, and around 100 pixels from the right side. The problem is, is that my app must be resizable. And I don't want to put box and button in a frame or canvas.

  • I encourage you to consider using a frame to contain the entry and button, and to use `pack` rather than `place` to arrange the widgets in the frame. `pack` makes it very easi to align widgets along the sides of a containing widget. – Bryan Oakley Jun 30 '22 at 13:21

1 Answers1

1

You can combine relx and x options to put the two widgets at the right side of the window:

# search textbox + search button
search_box = customtkinter.CTkEntry(master=root, placeholder_text="CTkEntry")
search_box.place(relx=1, x=-200, y=12.5, width=300, height=25, anchor=tkinter.NE)

search_button= customtkinter.CTkButton(master=root, text="search", command=place_flag)
search_button.place(relx=1, x=-100, y=12.5, width=75, height=25, anchor=tkinter.NE)
acw1668
  • 40,144
  • 5
  • 22
  • 34