This is a follow-on to an answered post - I assume it's poor form to add to an answered thread even if it's related.
Overall I'm pretty happy with the layout (heavy lifting done by Bryan O. here).
Now I'm trying to fine-tune some widgets, and I can't seem to nudge things. In order to shift widgets I seem to need to layer additional frames to do so. This seems like using a shotgun to kill a fly, but what do I know?
I would like to nudge the button 'Add Edges" over so it has some space between it and the number entry widget to the left.
I would also love to have some space between the ok and cancel buttons on the bottom. Have tried adding padding via padx, and implementing layered frames whacks things up bad layout truncated central region pretty badly.I guess that geometry propagation means using padx isn't the right approach.
I cannot seem to nudge the widgets where I want them. My question specifically: using the code base I have, how do you recommend I make these fine-tune adjustments??
Thx
code:
from Tkinter import *
root2 = Tk()
root2.title('Model Definition')
root2.geometry('{}x{}'.format(460, 350))
# functions/commands
def get_list(event):
global seltext
"""
read the listbox selection and put the result somewhere
"""
# get selected line index
index = data_list.curselection()[0]
# get the line's text
seltext = data_list.get(index)
root2.update_idletasks()
# create all of the main containers
top_frame = Frame(root2, bg='cyan', width = 450, height=50, pady=6)
center = Frame(root2, bg='gray2', width=50, height=40, padx=3, pady=3)
btm_frame = Frame(root2, bg='plum4', width = 450, height = 45, pady=3)
btm_frame2_outer = Frame(root2, bg='lavender', width = 450, height = 60, pady=3)
btm_frame2 = Frame(btm_frame2_outer, bg='green', width = 350, height = 60, pady=3)
btm_frame2_cntr = Frame(btm_frame2_outer, bg='gray', width = 50, padx=7)
# layout all of the main containers
root2.grid_rowconfigure(1, weight=1)
root2.grid_columnconfigure(0, weight=1)
top_frame.grid(row=0, sticky="ew")
center.grid(row=1, sticky="nsew")
btm_frame.grid(row = 3, sticky="ew")
btm_frame2_outer.grid(row = 4, sticky="ew")
btm_frame2.grid(row = 1, columnspan = 2, sticky="ew")
btm_frame2_cntr.grid(row = 1, column = 4, sticky='ew')
# create the widgets for the top frame
model_label = Label(top_frame, text = 'Model Dimensions')
width_label = Label(top_frame, text = 'Width:')
length_label = Label(top_frame, text = 'Length:')
entry_W = Entry(top_frame, background="pink")
entry_L = Entry(top_frame, background="orange")
# layout the widgets in the top frame
model_label.grid(row = 0, column = 0, pady=5)
width_label.grid(row = 1, column = 0, sticky = 'e')
length_label.grid(row = 1, column = 2)
entry_W.grid(row = 1, column = 1)
entry_L.grid(row = 1, column = 3)
# create the center widgets
center.grid_rowconfigure(0, weight=1)
center.grid_columnconfigure(1, weight=1)
ctr_left = Frame(center, bg='blue', width=100, height=190)
ctr_mid = Frame(center, bg='yellow', width=250, height=190, padx=3, pady=3)
ctr_right = Frame(center, width=100, height=190, padx=3, pady=3)
ctr_left.grid(row=0, column = 0, sticky="ns")
ctr_mid.grid(row=0, column = 1, sticky="nsew")
ctr_right.grid(row=0, column = 2, sticky="ns")
# decorate the center frame widgets
# left
shift_up_label = Label(ctr_left, text = 'Shift Up')
shift_down_label = Label(ctr_left, text = 'Shift Down')
cut_label = Label(ctr_left, text = 'Cut')
copy_label = Label(ctr_left, text = 'Copy')
paste_label = Label(ctr_left, text = 'Paste')
# center
data_list = Listbox(ctr_mid, bg='snow2', width='55')
yscroll = Scrollbar(ctr_mid, command=data_list.yview, orient=VERTICAL)
# right
status_label = Label(ctr_right, text = 'Status', bg = 'green', height = 11)
#####################################################################
# layout the center widgets
#####################################################################
#left
shift_up_label.grid(row = 0, column = 0, pady = '7', sticky = 'nsew')
shift_down_label.grid(row = 1, column = 0, pady = '7', sticky = 'nsew')
cut_label.grid(row = 2, column = 0, pady = '7', sticky = 'nsew')
copy_label.grid(row = 3, column = 0, pady = '7', sticky = 'nsew')
paste_label.grid(row = 4, column = 0, pady = '7', sticky = 'nsew')
# center
data_list.grid(row=0, column=0, sticky='ns')
yscroll.grid(row=0, column=0, sticky='ens')
# right
status_label.grid(row = 2, column = 0, rowspan = 4, sticky = 'nsew')
# create the bottom widgets
# layout the bottom widgets
#####################################################################
# create bottom widgets
#####################################################################
label_label = Label(btm_frame, text = 'Label:', padx = '4')
entry_label = Entry(btm_frame, background="orange")
entry_number = Entry(btm_frame, background="cyan")
number_label = Label(btm_frame, text = 'Number:', padx = '4')
add_btn = Button(btm_frame, text='Add Edges', padx = '12')
ok_btn = Button(btm_frame2_cntr, text='OK', padx = '5')
cancel_btn = Button(btm_frame2_cntr, text='Cancel', padx = '12')
#####################################################################
# layout the bottom widgets
#####################################################################
label_label.grid(row = 1, column = 1, sticky = 'ew')
entry_label.grid(row = 1, column = 2, sticky = 'w')
number_label.grid(row = 1, column = 3, sticky = 'w')
entry_number.grid(row = 1, column = 4, sticky = 'e')
add_btn.grid(row = 1, column = 6, sticky = 'e')
ok_btn.grid(row = 0, column = 3, sticky = 'ew')
cancel_btn.grid(row = 0, column = 4, sticky = 'e')
# commands/bindings
data_list.configure(yscrollcommand=yscroll.set)
data_list.bind('<ButtonRelease-1>', get_list)
root2.mainloop()