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

  • Home
  • SEARCH
  • 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 8518183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:54:41+00:00 2026-06-11T05:54:41+00:00

I want to create a GUI program base on tkinter. One of the widgets

  • 0

I want to create a GUI program base on tkinter. One of the widgets is Text. I want to add a horizontal scrollbar in it, but it didn’t work.

Where did I make a mistake?

from Tkinter import *
import tkFont


class DpWin(object):

    def run(self):
        root=Tk()
        root.geometry('768x612')
        title='dp'
        root.title(title)

        xscrollbar = Scrollbar(root, orient=HORIZONTAL)
        xscrollbar.pack(side=BOTTOM, fill=X)

        yscrollbar = Scrollbar(root)
        yscrollbar.pack(side=RIGHT, fill=Y)

        text = Text(root,xscrollcommand=xscrollbar.set,yscrollcommand=yscrollbar.set)
        text.pack()

        xscrollbar.config(command=text.xview)
        yscrollbar.config(command=text.yview)
        text.insert(END,'a'*999)
        mainloop()

    def start(self):
        self.b_start.config(state=DISABLED)
        self.b_stop.config(state=ACTIVE)

    def stop(self):
        self.b_stop.config(state=DISABLED)
        self.b_start.config(state=ACTIVE)


if __name__=='__main__':
    win=DpWin()
    win.run()
  • 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-11T05:54:42+00:00Added an answer on June 11, 2026 at 5:54 am

    I’ve modified your code according to here. There are 2 main differences.

    1. I made it so the textbox doesn’t wrap. If you wrap text, there is nothing for the horizontal scrollbar to scroll to.

    2. I used the grid geometry manager on a frame to keep the scrollbars and text widgets together. The advantage to using .grid is that you actually get scrollbars which are the correct width/height (something you can’t achieve with pack).

    …

    from Tkinter import *
    import tkFont
    
    class DpWin(object):
        def run(self):
            root=Tk()
            root.geometry('768x612')
            title='dp'
            root.title(title)
    
            f = Frame(root)
            f.pack()
    
            xscrollbar = Scrollbar(f, orient=HORIZONTAL)
            xscrollbar.grid(row=1, column=0, sticky=N+S+E+W)
    
            yscrollbar = Scrollbar(f)
            yscrollbar.grid(row=0, column=1, sticky=N+S+E+W)
    
            text = Text(f, wrap=NONE,
                        xscrollcommand=xscrollbar.set,
                        yscrollcommand=yscrollbar.set)
            text.grid(row=0, column=0)
    
            xscrollbar.config(command=text.xview)
            yscrollbar.config(command=text.yview)
            text.insert(END, 'a'*999)
            mainloop()
    
        def start(self):
            self.b_start.config(state=DISABLED)
            self.b_stop.config(state=ACTIVE)
    
        def stop(self):
            self.b_stop.config(state=DISABLED)
            self.b_start.config(state=ACTIVE)
    
    if __name__=='__main__':
        win=DpWin()
        win.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a mainly GUI Cocoa app, but I want to create a command
I'm generating a MATLAB GUI using GUIDE, but I want to create fields when
I want to create a very simple HTML/AJAX based GUI for a Python program.
I want to create a GUI in which the combo-box allows me to open
So basically I want to create a GUI app using PySide and the Qt
I would like to know if there is a way to create GUI program,
basically, I have a program that has a class to create a basic GUI,
I want to create a program that will take user input and create a
I've written a simple GUI program in python using Tkinter. Let's call this program
What I want to do is create a semi-transparent overlay over another program's window

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.