Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8422983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:36:30+00:00 2026-06-10T03:36:30+00:00

The TkDocs website is a great resource, but it is not complete. The manpage

  • 0

The TkDocs website is a great resource, but it is not complete. The manpage is complete, but of course does not document Python bindings. ” How to get the screen size in Tkinter? ” points out that the window size can be obtained using root.winfo_screenwidth() / root.winfo_screenheight(), but that addresses only the full window, not individual cells within a grid.

Using the TkDocs code as an example, how can I find the height of, e.g., the third row so that I can set a minsize that prevents the buttons from being hidden? Nothing I’ve tried using bbox() or grid_bbox() returns anything other than (0,0,0,0). What is the proper syntax for returning an actual size?

—– Edit —–

The code now shows how bbox() is used within routines called from the event loop, returning correct values.

from tkinter import *
from tkinter import ttk

# bbox() works after window has been rendered
def e_config(event):
    w, h = event.width, event.height
    print("Resize: content", w, "x", h)
    print("content bbox=", content.bbox())

def OK():
    print("OK: winfo, bbox:")
    print("    root: ", root.winfo_width(), root.winfo_height(), root.bbox())
    print(" content: ", content.winfo_width(), content.winfo_height(), content.bbox())
    print("   frame: ", frame.winfo_width(), frame.winfo_height(), frame.bbox())

root = Tk()

content = ttk.Frame(root, padding=(5,5,12,12))
content.bind("<Configure>", e_config)

frame = ttk.Frame(content, borderwidth=5, relief="sunken", width=200, height=100)
namelbl = ttk.Label(content, text="Name")
name = ttk.Entry(content)

onevar = BooleanVar()
twovar = BooleanVar()
onevar.set(True)
twovar.set(False)

one = ttk.Checkbutton(content, text="One", variable=onevar, onvalue=True)
two = ttk.Checkbutton(content, text="Two", variable=twovar, onvalue=True)
ok = ttk.Button(content, text="Okay", command=OK)
cancel = ttk.Button(content, text="Cancel")

content.grid(column=0, row=0, sticky=(E, W))    # Don't resize vertically
frame.grid(column=0, row=0, columnspan=3, rowspan=2)
namelbl.grid(column=3, row=0, columnspan=2)
name.grid(column=3, row=1, columnspan=2)
one.grid(column=0, row=3)
two.grid(column=1, row=3)
ok.grid(column=3, row=3)
cancel.grid(column=4, row=3)

root.configure(bg="#234")
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
content.columnconfigure(0, weight=1)
content.columnconfigure(1, weight=1)
content.columnconfigure(2, weight=1)
content.columnconfigure(3, weight=1)

# This doesn't work - screen hasn't been rendered yet
print("pre-init bbox ", content.bbox())

root.mainloop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:36:32+00:00Added an answer on June 10, 2026 at 3:36 am

    The methods winfo_width and winfo_height will give you the actual size of a given widget.

    Note that neither these methods, nor bbox, will give you anything useful until the widgets are actually rendered to the screen. If you need to use them you will need to make sure the event loop has had a chance to update the display.

    Also, be aware that the bbox method returns the bounding box of the slave widgets inside the widget, not the bounding of of the widget itself. That is why the results for frame.grid_bbox() return all zeros — it has nothing inside it so the bounding box is 0,0,0,0. You should, however, see numbers for content.box() once the display has been rendered. On my box, for instance, I get (0, 0, 352, 125)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen this code documented in the tk docs, but I can't figure
i've already read all topics here and on google about redirection but i'm a
According to TkDocs : The 1.0 here represents where to insert the text, and
I have a ASP table that I create dynamically on the page load event.
I have the following code: from tkinter import * class MyApplication(Tk): def __init__(self): super().__init__()
I am trying to use the invoke method of a ttk.Button, as shown at
I am trying to run a simple ruby program on windows platform using 'tk'
I am trying to access the label of a button in Tkinter, when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.