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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:25:35+00:00 2026-05-17T02:25:35+00:00

With this code, the window is 500 by 500, which is what I’m going

  • 0

With this code, the window is 500 by 500, which is what I’m going for:

from tkinter import *
root = Tk()

frame = Frame(root, width=500, height=500)

frame.pack()
root.mainloop()

When I add a text box to the frame, though, it shrinks to just the size of the text box:

from tkinter import *
root = Tk()

frame = Frame(root, width=500, height=500)

text = Text(frame, width=10, height=2) # THESE TWO
text.pack()                            # LINES HERE

frame.pack()
root.mainloop()

Why does this happen, and how can I prevent it from happening?

  • 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-05-17T02:25:35+00:00Added an answer on May 17, 2026 at 2:25 am

    The frame by default has “pack propagation” turned on. That means the packer “computes how large a master must be to just exactly meet the needs of its slaves, and it sets the requested width and height of the master to these dimensions” (quoting from the official tcl/tk man pages [1]).

    For the vast majority of cases this is the exact right behavior. For the times that you don’t want this you can call pack_propagate on the master and set the value to false. I think in close to 20 years of tk programing I’ve only needed to do this a half dozen times or so, if that.

    Another choice you have is to use wm_geometry to set the size of the toplevel after you’ve created all the widgets. This does effectively the same thing as if the user had manually resized the window. This only works for toplevel windows though, you can’t use wm_geometry on a frame.

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

Sidebar

Related Questions

I have this code which draws a Window and NSView, and have set up
I have this code window.onload = function() { function foo() { alert(test); } setInterval(foo(),500)
I've found this code $(window).scroll(function(){ $('#header').css({ //Why this 15, because in the CSS, we
I have this code: public class Window extends JFrame { public Window(){ ... JButton
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
This code works (when ControlType=dropDown then the background yellow ): <Window x:Class=TestCollapsed.Views.MainView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
I have got this code: function init(){ if (typeof window.jQuery !== 'function') { var
I have this code inside a iframe: window.addEventListener('message', function(e){ if(e.data == 'test') console.log(e); },
I am currently using this code to bring up an info window -(IBAction)showInfo:(id)sender {
I have some html5 postMessage code: window.addEventListener(message, FA.recieveMessage, false); That listener invokes this function:

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.