79713753

Date: 2025-07-24 17:30:53
Score: 2.5
Natty:
Report link

Good question!

Both `.geometry("400x400")` and `.config(width=400, height=400)` can be used to resize a `Tk` window, but they behave a bit differently:

`.geometry("400x400")`

- This sets the **entire size of the root window**, including window decorations like borders and the title bar.

- It accepts a string in the format `"widthxheight"`, and is the standard way to size the main window.

`.config(width=..., height=...)`

- This sets the **internal dimensions** of the window’s content area (the client area).

- Depending on the platform and window manager, the total window size might become slightly larger due to decorations.

Which one should you use?

- For setting the initial size of a `Tk()` root window, `.geometry()` is generally preferred because it accounts for the full window.

-Use `.config()` more often for widgets (like `Frame`, `Canvas`, etc.) rather than the root window itself.

[Official tkinter docs on geometry](https://docs.python.org/3/library/tkinter.html#geometry-method)

Hope this clears it up!

Reasons:
  • Blacklisted phrase (1): thx
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: reza khalili