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 7902717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:34:30+00:00 2026-06-03T09:34:30+00:00

The reason I’m doing this is because I’m trying to set the window in

  • 0

The reason I’m doing this is because I’m trying to set the window in the centre of the screen. I’m using grid not pack and I have read about using wm grid but don’t understand how to set it. I also don’t understand why . cget -width is returning 0 I thought grid was supposed to set the size when not given an option?

set width [. cget -width]
set height [. cget -height]
puts $height
puts $width
set x [expr { ( [winfo vrootwidth  .] - $width  ) / 2 }]
set y [expr { ( [winfo vrootheight .] - $height ) / 2 }]


wm title . "a3q2" 
wm geometry . ${width}x${height}+${x}+${y}

What am I doing wrong this time? P.S homework I don’t just want a code post. Thanks

  • 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-03T09:34:31+00:00Added an answer on June 3, 2026 at 9:34 am

    [. cget -width] and [. cget -height] return the explicitly configured width/height of the window. For most widgets in Tk you don’t explicitly configure the dimensions. Instead, the widgets have a “natural” width/height based on the contents of the widget. A label, for example, is just wide/tall enough to accommodate the text in it. A toplevel window is just big enough to fit all the widgets inside of it.

    To get the actual dimensions of the window, you should use [winfo width .] and [winfo height .]. Make sure you do that after the window and all of the widgets inside it have been mapped (usually that means doing an [update] call before the [winfo ...] calls). Otherwise the geometry manager may not have updated the dimensions of the widgets/window yet.

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

Sidebar

Related Questions

The reason I'm trying to do this, is that I have a program that
The reason I am asking this, is because extending the Similarity class or using
The reason I am asking this question is because I have landed my first
The reason why I ask this is because I need to know whether not
The reason I'm asking this is because there is a validation in OpenERP that
Reason why I want to run them individually, is because I need to have
The reason I want to do this is because I am having trouble changing
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
The reason this is happening obviously is because of the Gray box above. Now
The reason why I am stuck on this is because of how C handles

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.