Can I create different row numbers inside two columns using tkinter?

Viewed 335

First of all, this is my first topic and I would like to greet you all and in advance thank you for all your help. I am a programming newbie. I started learning python a few months ago and now I'm trying to make (and I did it) a functional GUI for a friend, but my "customer" has some layout wishes and I'm having trouble arranging it the way he wants me to. This is how I need it to look like:

enter image description here

Basically, if I know how to create different row numbers inside two columns, I might even do it by myself. I've searched online but couldn't find the solution.

1 Answers

You can nest widget management tools by using the Frame widget.

root = tk.Tk()
left_side = tk.Frame(root)
right_side = tk.Frame(root)
left_side.grid(row=0, column=0)
right_side.grid(row=0, column=1)

entrybox = tk.Entry(left_side, ...args...)
listbox1 = tk.Entry(left_side, ditto)
listbox2 = tk.Entry(left_side, etc)
listbox3 = tk.Entry(left_side, yeah)
entrybox.grid(row=0, column=0)
listbox1.grid(row=2, column=0)
listbox2.grid(row=3, column=0)
listbox3.grid(row=4, column=0)

spinbox = tk.Spinbox(right_side, . . . )
< all those things >
spinbox.grid(row=0, column=0)
the_next_one.grid(row=1, column=0)

that's just an example, and I left a lot to be filled in, but I hope that shows you what I am talking about

You can also use columnspan and rowspan, take a good look at this page: https://effbot.org/tkinterbook/grid.htm You could have that top listbox span 5 or 6 rows and put all the buttons on the right in those rows but in the right column.

Hope that helps, feel free to ask questions or for more examples!

Related