I am new to tkinter and learning to create simple widgets. I have encountered on issue, when I was creating many buttons to click, I found that the spacing between the buttons is not uniform and it becomes more congested as it goes left to right.
MWE
How to make spacing between buttons uniform?
%%writefile a.py
import sys
import tkinter as tk
from tkinter import ttk,messagebox
win = tk.Tk()
def countdown(win):
child = tk.Toplevel(win)
child.geometry('400x300')
child.resizable(0, 0)
# label: current time title
tk.Label(child, font='arial 15 bold', text='current time :').place(x=40, y=70)
tk.Label(child, font='arial 15 bold', text='set the time').place(x=40, y=150)
tk.Label(child,text='',fg='gray25').place(x=190, y=70)
frame_top = tk.Frame(child)
frame_top.pack(expand=False, fill=tk.X)
frame_bottom = tk.Frame(child)
frame_bottom.pack(expand=False, fill=tk.X)
mins = [1,2,5,10,15,20,25,30,35,40]
for i,minn in enumerate(mins):
tk.Button(frame_top,text=str(minn)+'m',bd='5',).pack(expand=True, side=tk.LEFT)
for i,minn in enumerate([45,50,55,60,90,120,150,180]):
tk.Button(frame_bottom,text=str(minn)+'m',bd='5',).pack(expand=True, side=tk.LEFT)
menubar = tk.Menu(win)
menu = tk.Menu(menubar, tearoff=0)
menubar.add_cascade(label="Scripts", menu=menu)
menu.add_command(label='Countdown',command=lambda : countdown(win))
menu.add_command(label='Exit',command=sys.exit)
win.config(menu=menubar)
win.mainloop()