[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tkinter spacing

If I want to have some space between, say, btn_last & btn_new, will I have to use a dummy label in between these two or is there a better way?

Thanks for any help, as always!

from tkinter import *
from tkinter import ttk

root = Tk()
nav_bar = ttk.Frame(root, borderwidth=2, relief='ridge', padding=(10, 3, 10, 3))

btn_first  = ttk.Button(nav_bar, text='|<', width=4)  # for buttons showing text only, this will be text units (= average characters?)
btn_prev   = ttk.Button(nav_bar, text='<',  width=4)  # for image buttons, it will be in pixels 
btn_next   = ttk.Button(nav_bar, text='>',  width=4)
btn_last   = ttk.Button(nav_bar, text='>|', width=4)
btn_new    = ttk.Button(nav_bar, text='New')
btn_edit   = ttk.Button(nav_bar, text='Edit')
btn_delete = ttk.Button(nav_bar, text='Delete')
btn_cancel = ttk.Button(nav_bar, text='Cancel')
btn_print  = ttk.Button(nav_bar, text='Print')
btn_help   = ttk.Button(nav_bar, text='Help')
btn_save   = ttk.Button(nav_bar, text='Save')
lbl_Recs   = ttk.Label(nav_bar,  text='Records')
lbl_RCount = ttk.Label(nav_bar,  text='0 ', width=10, borderwidth=2, relief='sunken', anchor='e')  # fake entry look

nav_bar.grid(column=0, row=0, columnspan=13)

btn_first.grid(column=0, row=0)
btn_prev.grid(column=1,  row=0)
btn_next.grid(column=2,  row=0)
btn_last.grid(column=3,  row=0)

btn_new.grid(column=4,    row=0)
btn_edit.grid(column=5,   row=0)
btn_delete.grid(column=6, row=0)
btn_cancel.grid(column=7, row=0)

lbl_Recs.grid(column=8,   row=0, padx=5)
lbl_RCount.grid(column=9, row=0, padx=5)
btn_print.grid(column=10, row=0)
btn_help.grid(column=11,  row=0)
btn_save.grid(column=12,  row=0)