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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:55:34+00:00 2026-05-13T17:55:34+00:00

I am using Python 3.1 by the way. I am trying to build a

  • 0

I am using Python 3.1 by the way.

I am trying to build a simple GUI using Tkinter – label, text entry field, button on the first row and editable text area with scrollbar to the right and on the bottom of it – on the second row. Please help me fix up the layout. What I have below does not quite work. If I have to use a grid, I will. I wish to keep the code very simple – I want to “sell” Python to some of my coworkers. So, I want to get a somewhat decent look and feel. Suggest better padding if you do not mind. Also, if my variable names, etc. seem weird, then please make a note.

At the same time I want to pretend that this is a throw-away script which I have not spent much time on. Since I am asking for your help, it ain’t so, but they do not need to know ;). So, I do not want to introduce fancy code to create nice borders, etc. I just want something that is visually appealing, clean and simple. If I do not, then my presentation will not achieve its goal.

Thank you, my code is below:

class App:
    def __init__(self, parent):
        frame = Frame(parent)
        self.__setup_gui(frame) # Call Helper
        frame.pack(padx=15, pady=15)
        parent.title('To be changed')

    def __setup_gui(self, frame):

        # First Row
        self.cs_label = Label(frame, text='Change Set: ')
        self.cs_label.pack(side=LEFT, padx=10, pady=10)

        self.cs_val = Entry(frame, width=10)
        self.cs_val.pack(side=LEFT, padx=10, pady=10)

        self.get_button = Button(frame, text='Get', command=self.get_content)
        self.get_button.pack(side=LEFT, padx=10, pady=10)

        # Text area and scrollbar
        self.text_area = Text(frame, height=10, width=50, background='white')
        # Put a scroll bar in the frame
        scroll = Scrollbar(frame)
        self.text_area.configure(yscrollcommand=scroll.set)
        self.text_area.pack(side=TOP)
        scroll.pack(side=RIGHT,fill=Y)

        self.clipboard_var = IntVar()
        self.notepad_var = IntVar()

    def get_content(self):
        print(self.clipboard_var.get())
        print(self.notepad_var.get())

###################################################################################################

if __name__ == '__main__':
    root = Tk()
    app = App(root)
    root.mainloop()
  • 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-13T17:55:35+00:00Added an answer on May 13, 2026 at 5:55 pm

    You definitely want the grid manager — Pack only works for a vertical or horizontal stackup by itself. You can use multiple frames to work around it, but I find it’s easier to expand a GUI if you just do it with Grid to start.

    Here’s what I’ve worked up real quick based what you said and the code. I reduced/removed the padding — it looked huge for me — and I set up two scrollbars, in a subframe to make the padding work out more easily. Note that to make the horizontal scrollbar useful your Text area needs to have wrap=NONE; otherwise you might as well use the easy ‘ScrolledText’ widget from tkinter.scrolledtext and skip the horizontal scroll bar.

    I’ve now reframed things a bit to allow for resize, with a minimum size that shows the top buttons — see the uses of minsize and row/columnconfigure.

    BTW, it looks like your variables aren’t being pulled from anywhere — is that intentional?

    from tkinter import *
    
    class App:
        def __init__(self, parent):
            self.__setup_gui(parent) # Call Helper
            parent.title('To be changed')
    
        def __setup_gui(self, parent):
    
            # First Row
            self.rowframe = Frame(parent)
            self.rowframe.grid()
            self.cs_label = Label(self.rowframe, text='Change Set: ')
            self.cs_label.grid(row=0, column=0, padx=2, pady=2)
    
            self.cs_val = Entry(self.rowframe, width=10)
            self.cs_val.grid(row=0, column=1, padx=2, pady=2)
    
            self.get_button = Button(self.rowframe, text='Get', command=self.get_content)
            self.get_button.grid(row=0, column=2, padx=2, pady=2)
            parent.update_idletasks()
            parent.minsize(width=self.rowframe.winfo_width(), height=self.rowframe.winfo_height())
    
            # Text area and scrollbars
            self.textframe = Frame(parent)
            self.textframe.grid(row=1, columnspan=2, padx=2, pady=2, sticky=N+S+E+W)
    
            self.hscroll = Scrollbar(self.textframe, orient=HORIZONTAL)
            self.vscroll = Scrollbar(self.textframe)
            self.text_area = Text(self.textframe, height=10, width=50, wrap=NONE, background='white', yscrollcommand=self.vscroll.set, xscrollcommand=self.hscroll.set)
            self.text_area.grid(row=0, column=0, sticky=N+S+E+W)
            self.hscroll.config(command=self.text_area.xview)
            self.hscroll.grid(row=1, column=0, sticky=E+W)
            self.vscroll.config(command=self.text_area.yview)
            self.vscroll.grid(row=0, column=1, sticky=N+S)
    
            # Row 0 defaults to 0
            parent.rowconfigure(1, weight=1)
            parent.columnconfigure(1, weight=1)
    
            # Textarea setup
            self.textframe.rowconfigure(0, weight=1)
            self.textframe.columnconfigure(0, weight=1)
    
    
            self.clipboard_var = IntVar()
            self.notepad_var = IntVar()
    
        def get_content(self):
            print(self.clipboard_var.get())
            print(self.notepad_var.get())
    
    ###################################################################################################
    
    if __name__ == '__main__':
        root = Tk()
        app = App(root)
        root.mainloop()
    

    Now, all that said…you might get more visual appeal with PyGTK, PyQt, or wxPython, though tkinter coming “standard” is a nice feature.

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

Sidebar

Ask A Question

Stats

  • Questions 421k
  • Answers 421k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, classrating is effectively the same as classname. So you're… May 15, 2026 at 11:05 am
  • Editorial Team
    Editorial Team added an answer I'm thinking you probably do have two different objects, but… May 15, 2026 at 11:05 am
  • Editorial Team
    Editorial Team added an answer Write the scale value to a file and read it… May 15, 2026 at 11:05 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.