I have a window with a listbox that resize with one another. I'm using grid for this. There are a row of buttons under the list box which are currently moving and resizing with the window. I'd like the buttons to remain in place and remain a consistent size while window and listbox resize (so the buttons always remain in the bottom left corner of the listbox).
Is there an easy way to do this? I just started using Tkinter today so I may have just missed it in the docs or might just be confused on grid layouts.
The buttons are set up as follows:
nextbutton = Button(self, width = 30, height = 30, image = ffbtn)
nextbutton.image = ffbtn
nextbutton.bind("<Button-1>", self.forward)
nextbutton.grid(row = 10, column=4, sticky='w')
I've tried all sticky combinations but the ones that don't resize the buttons still allow them to move around, which I don't want.
EDIT: Heres an very basic example of what I'm talking about, as requested. When the window is resized, the buttons move apart from each other. I don't want that.
On a side note, do I need all those grid configures at the end to set the weight even if I use its one column or row with column/rowspan taking up all the space?
import tkinter
from tkinter import *
from tkinter import ttk
class Application(tkinter.Tk):
def __init__(self, parent):
tkinter.Tk.__init__(self, parent)
self.minsize(300,300)
self.parent = parent
self.main()
def main(self):
self.grid()
listbox = tkinter.Listbox(self, width=20, height=25, bg = 'grey')
listbox.grid(padx=30, pady=30, columnspan=11, sticky='NEW')
bt1 = Button(self, width = 5, height = 5)
bt1.grid(row=10, column=0, padx=(30,0), sticky='w')
bt2 = Button(self, width = 5, height = 5)
bt2.grid(row = 10, column=1, sticky='w')
bt3 = Button(self, width = 5, height = 5)
bt3.grid(row = 10, column=2, sticky='w')
bt4 = Button(self, width = 5, height = 5)
bt4.grid(row = 10, column=3, sticky='w')
bt5 = Button(self, width = 5, height = 5)
bt5.grid(row = 10, column=4, sticky='w')
self.grid_columnconfigure(0,weight=1)
self.grid_columnconfigure(1,weight=1)
self.grid_columnconfigure(2,weight=1)
self.grid_columnconfigure(3,weight=1)
self.grid_columnconfigure(4,weight=1)
self.grid_columnconfigure(5,weight=1)
self.grid_columnconfigure(6,weight=1)
self.grid_columnconfigure(7,weight=1)
self.grid_columnconfigure(8,weight=1)
self.grid_columnconfigure(9,weight=1)
self.grid_columnconfigure(10,weight=1)
self.grid_rowconfigure(0,weight=1)
self.grid_rowconfigure(1,weight=1)
self.grid_rowconfigure(2,weight=1)
self.grid_rowconfigure(3,weight=1)
self.grid_rowconfigure(4,weight=1)
self.grid_rowconfigure(5,weight=1)
self.grid_rowconfigure(6,weight=1)
self.grid_rowconfigure(7,weight=1)
self.grid_rowconfigure(8,weight=1)
self.grid_rowconfigure(9,weight=1)
self.grid_rowconfigure(10,weight=1)
app = Application(None)
app.mainloop()