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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:52:18+00:00 2026-05-18T20:52:18+00:00

I’d like a to make a scrolled Tkinter textbox that fills the maximum alloted

  • 0

I’d like a to make a scrolled Tkinter textbox that fills the maximum alloted space. I have it working kind of…

For some reason when I stretch the window the text widget is fine; However, the scroll bar gets a ton of padding on the x axis.

The second problem is when I shrink the window the scrollbar goes of the screen.

Anyone know the solutions to these two programs?

snippet:

    self.Fr = Tkinter.Frame(self, width=self.Wi, height=self.He)
    self.Fr.pack(side='right', fill='both', expand='yes')


    self.Te = Tkinter.Text(self.Fr, font=self.Fo, fg=self.FG, bg=self.BG,
                           selectforeground=self.SFG,
                           selectbackground=self.SBG,
                           insertbackground=self.IBG, wrap='word',
                           undo=True, maxundo=100)
    #self.Te.grid(column=0, row=0, sticky='NSEW')
    self.Te.pack(side='left', fill='both', expand='yes')


    self.Sc = Tkinter.Scrollbar(self.Fr, elementborderwidth=1)
    #self.Sc.grid(column=1, row=0, sticky='NSEW')
    self.Sc.pack(side='right', fill='both', expand='yes')

    self.Te.configure(yscrollcommand=self.Sc.set)
    self.Sc.configure(command=self.Te.yview)
  • 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-18T20:52:19+00:00Added an answer on May 18, 2026 at 8:52 pm

    Your scrollbar gets all the padding because you use fill='both'. Even though it’s a vertical scrollbar you asked it to take up extra space along the x axis, which results in the padding since the scrollbar itself won’t stretch to make a wide scrollbar. You want vertical scrollbars to only fill in the Y direction and horizontal ones to fill in the X direction.

    As to the scrollbar going off screen, that’s a little complex to explain but it has a simple solution.

    The problem is this: if you shrink a window managed by pack to a point where it’s smaller than that required by the widgets inside, it starts clipping widgets. The way this works is it processes the widgets in order, laying out the window and then allocating any left-over space for any remaining widgets. This means that if a widget early in the order takes up all the remaining visual space, any later widgets will not appear.

    The “order” mentioned above is the order of the packing list. Specifically, the order in which items were packed. So, if you pack the text widget and then the scrollbar Tk will first lay out the text widget, and any remaining space will be allocated to the scrollbar. IF you had packed the scrollbar first, it would get laid out and any remaining space would be given to the text widget.

    It all sounds very complex, but the cool thing is that if you pack things in the proper order it all just works.

    The general rule of thumb, then, is to make sure the last widget you pack is the one with expand set to true. This is your “elastic” widget. That way all the fixed-size widgets will take up whatever space they need first, and your “elastic” widget will take up all that is left.

    There is another solution which is to give your text widget a requested width and height of one. With that, when the packer initially allocates space it will allocate only a small amount of space. Thus, when the window shrinks the text widget will shrink until it gets down to that tiny size. This isn’t very practical though, since one of the great features of pack is that you can give all widgets their natural size (or they assume their natural size based on their content in the case of buttons and labels) and the packer does all the work. If you set the width and height to one, your initial window (unless explicitly set to a larger size) will be rather small.

    This behavior is all documented in the man page for pack, though you have to read it really closely to fully grasp this behavior.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.