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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:19:04+00:00 2026-05-18T12:19:04+00:00

I’m trying to make a simple GUI calculator in Python with Tkinter. However the

  • 0

I’m trying to make a simple GUI calculator in Python with Tkinter. However the widths of the buttons will often be off by 1 or 2 pixels. Is there any way to force all the buttons to have the same width.

I know of the ipadx method; however, it adds pixels to both sides of the button. This causes problems when the widths of the buttons are odd.

So what’s the best method to impose a uniform width?

This is my code:

self.SC.Ca.Btn7 = Tkinter.Button(self.SC.Ca.BtnFrame, text="7", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn7.grid(column=0, row=0, padx=px, pady=py)

self.SC.Ca.Btn8 = Tkinter.Button(self.SC.Ca.BtnFrame, text="8", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn8.grid(column=1, row=0, padx=px, pady=py)

self.SC.Ca.Btn9 = Tkinter.Button(self.SC.Ca.BtnFrame, text="9", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn9.grid(column=2, row=0, padx=px, pady=py)

self.SC.Ca.Btn4 = Tkinter.Button(self.SC.Ca.BtnFrame, text="4", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn4.grid(column=0, row=1, padx=px, pady=py)

self.SC.Ca.Btn5 = Tkinter.Button(self.SC.Ca.BtnFrame, text="5", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn5.grid(column=1, row=1, padx=px, pady=py)

self.SC.Ca.Btn6 = Tkinter.Button(self.SC.Ca.BtnFrame, text="6", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn6.grid(column=2, row=1, padx=px, pady=py)

self.SC.Ca.Btn1 = Tkinter.Button(self.SC.Ca.BtnFrame, text="1", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn1.grid(column=0, row=2, padx=px, pady=py)

self.SC.Ca.Btn2 = Tkinter.Button(self.SC.Ca.BtnFrame, text="2", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn2.grid(column=1, row=2, padx=px, pady=py)

self.SC.Ca.Btn3 = Tkinter.Button(self.SC.Ca.BtnFrame, text="3", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn3.grid(column=2, row=2, padx=px, pady=py)

self.SC.Ca.Btn0 = Tkinter.Button(self.SC.Ca.BtnFrame, text="0", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.Btn0.grid(column=0, row=3, columnspan=2, ipadx=13, padx=px, pady=py)

self.SC.Ca.BtnPe = Tkinter.Button(self.SC.Ca.BtnFrame, text=".", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnPe.grid(column=2, row=3, ipadx=2, padx=px, pady=py)



self.SC.Ca.OppBtnFrame = Tkinter.Frame(self.SC.Ca.MainFrame, bd=self.SCbw, bg=self.SCbg)
self.SC.Ca.OppBtnFrame.grid(column=1, row=2)


self.SC.Ca.BtnPN = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="±", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnPN.grid(column=0, row=0, ipadx=4, padx=px, pady=py)

self.SC.Ca.BtnSl = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="/", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnSl.grid(column=0, row=1, ipadx=3, padx=px, pady=py)

self.SC.Ca.BtnSu = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="-", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnSu.grid(column=0, row=2, ipadx=2, padx=px, pady=py)

self.SC.Ca.BtnSR = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="√", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnSR.grid(column=1, row=0, ipadx=1, padx=px, pady=py)



self.SC.Ca.BtnCl = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="C", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnCl.grid(column=0, row=3, ipadx=0, padx=px, pady=py)

self.SC.Ca.BtnSt = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="*", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnSt.grid(column=1, row=1, ipadx=1, padx=px, pady=py)

self.SC.Ca.BtnAd = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="+", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnAd.grid(column=1, row=2, ipadx=1, padx=px, pady=py)

self.SC.Ca.BtnEq = Tkinter.Button(self.SC.Ca.OppBtnFrame, text="=", bd=self.SCbw, fg=self.SCfg,
                                 bg=self.SCbg, activeforeground=self.SCfg, activebackground=self.SCbg, font=self.SCfob)
self.SC.Ca.BtnEq.grid(column=1, row=3, ipadx=1, padx=px, pady=py)
  • 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-18T12:19:04+00:00Added an answer on May 18, 2026 at 12:19 pm

    Use the sticky option of the grid geometry manager to “stick” the button to all four sides of its containing cell (i.e. Tkinter.N + Tkinter.S + Tkinter.E + Tkinter.W). If you want to enforce a minimum width then you can either set the button width or better use grid_columnconfigure.

    Also, really consider not using copy/paste in building your UI so much – if you’ve got multiple buttons with the same options, at least put them in a dictionary, use a function or functools.partial. Tkinter makes writing clean UI code very easy, and you’ll thank yourself later…

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

Sidebar

Related Questions

No related questions found

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.