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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:13:50+00:00 2026-06-15T18:13:50+00:00

I am trying to attach a scrollbar to my Text field and have been

  • 0

I am trying to attach a scrollbar to my Text field and have been unable to do so. Here is the segment of code:

self.scroller = Scrollbar(self.root)
self.scroller.place(x=706, y=121)
self.outputArea = Text(self.root, height=26, width=100) 
self.outputArea.place(x=0, y=120)
self.scroller.config(command=self.outputArea.yview)
self.outputArea.config(state=DISABLED, yscrollcommand = self.scroller.set)

This code is placing a very small scrollbar right next to my text field (and by very small, I mean that you can see the up and down arrows but nothing in between). I can scroll with it when my text field fills up, but is there a way to at the very least set the height of the scrollbar so that it appears to be the same height as the text field?

  • 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-15T18:13:51+00:00Added an answer on June 15, 2026 at 6:13 pm

    Tkinter has three geometry managers: pack, grid, and place.
    Pack and grid are usually recommended over place.

    You can use the grid manager’s row and column options
    to position the Scrollbar next to the Text widget.

    Set the Scrollbar widget’s command option to the Text’s yview method.

    scrollb = tkinter.Scrollbar(..., command=txt.yview)
    

    Set the Text widget’s yscrollcommand option to the Scrollbar’s set method.

    txt['yscrollcommand'] = scrollb.set
    

    Here’s a working example that makes use of ttk:

    import tkinter
    import tkinter.ttk as ttk
    
    class TextScrollCombo(ttk.Frame):
    
        def __init__(self, *args, **kwargs):
    
            super().__init__(*args, **kwargs)
    
        # ensure a consistent GUI size
            self.grid_propagate(False)
        # implement stretchability
            self.grid_rowconfigure(0, weight=1)
            self.grid_columnconfigure(0, weight=1)
    
        # create a Text widget
            self.txt = tkinter.Text(self)
            self.txt.grid(row=0, column=0, sticky="nsew", padx=2, pady=2)
    
        # create a Scrollbar and associate it with txt
            scrollb = ttk.Scrollbar(self, command=self.txt.yview)
            scrollb.grid(row=0, column=1, sticky='nsew')
            self.txt['yscrollcommand'] = scrollb.set
    
    main_window = tkinter.Tk()
    
    combo = TextScrollCombo(main_window)
    combo.pack(fill="both", expand=True)
    combo.config(width=600, height=600)
    
    combo.txt.config(font=("consolas", 12), undo=True, wrap='word')
    combo.txt.config(borderwidth=3, relief="sunken")
    
    style = ttk.Style()
    style.theme_use('clam')
    
    main_window.mainloop()
    

    The part that will address your Scrollbar being small is sticky='nsew',
    which you can read about → here.

    Something that will be helpful for you to learn right now is that different Tkinter widgets can use different geometry managers within the same program as long as they do not share the same parent.


    The tkinter.scrolledtext module contains a class called ScrolledText which is a compound widget (Text & Scrollbar).

    import tkinter
    import tkinter.scrolledtext as scrolledtext
    
    main_window = tkinter.Tk()
    
    txt = scrolledtext.ScrolledText(main_window, undo=True)
    txt['font'] = ('consolas', '12')
    txt.pack(expand=True, fill='both')
    
    main_window.mainloop()
    

    The way this is implemented is worth taking a look at.

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

Sidebar

Related Questions

I have been trying to attach a handler to the resize event in one
I am trying to attach onBlur and onFocus handler to a SSN input field.
in my spinner i am trying to attach an image and a text View,
I have a question related to this one : I'm trying to attach an
I have loaded Web Site from HDD. Now trying attach it to process WebDev.WebServer.EXE.
I'm trying to attach an image on a button in WPF, however this code
I am trying to attach a file with a contact form. My code looks
I have a user class, where I am trying to attach a profile created
I'm using this tickertype jquery plugin: http://www.hungry-media.com/code/jQuery/tickerType/ And I'm trying to attach a hover
So, I've been having a bit of trouble trying to attach files using a

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.