I have 2 Listboxes next to each other and I try to create a checkbox for each entry of these Listboxes. Unfortunately, I do not manage to make the checkboxes and listbox elements have the same height/be on the same position, as you can see in the screenshot below.
Do you have any idea how i can modify it to have something similar to checkboxes in a list(which is not possible in Tkinter afaik)? For my Listboxes, I use a customized version of this snippet: https://stackoverflow.com/a/16056555/3429131
I hope I explained my problem in an understandable way. Thanks for your help.
If it's not 100% necessary to have everything in a listbox then you could try and display the data using grid or pack which would make them line up properly, grid would probably be better.
Just declare it as something like:
master = Tk()
Model1 = Label(master, text="F45")
Part1 = Label(master, text="AUFN-BUCHSE")
Active1 = Checkbutton(master, variable=Var)
Model1.grid(row=0,column=0)
Part1.grid(row=0, column=1)
Active1.grid(row=0, column=2)
And if you wanted to repeat this you could pull the Model and Part sections out of a file and then create a for loop that creates a list containing the Labels.
You could then use a for loop to grid the labels, something like this:
for Counter1 in range(0, NumberOfRows)
Model[Counter1].grid(row=Counter1, column=0)
Part[Counter1].grid(row=Counter1, column=1)
Checkbutton.grid(row=Counter1, column=2)
Something along the lines of this, with a few tweaks, where Model[] would be something like [F45, F46, F47...] and Part[] would be [AUFN-BUCHSE, AUFN-BUCHSE-BOLZEN...]
Again you may have to tweak my code a little, not sure if it's spot on what you wanted but all of this depends on whether list boxes are completely necessary or not.
If you want to read up some more on gird method, check this out:
http://effbot.org/tkinterbook/grid.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With