0

So Tkinter has the grid system and frames and such. I've already made a basic layout, like so:

enter image description here

I added a massive space to it by using padding for its parent frame, but now I want to populate it. Does Tkinter support grids within grids and frames within frames? For instance, I tried:

layout = ttk.Frame(anchor, padding="250 5 250 500") #Appears to initialize its layout
layout.grid(column=0, row=0) #Appears to set up a grid system
layout.columnconfigure(0, weight=1)
layout.rowconfigure(0, weight=1)
contentspace = ttk.Frame(layout, padding="10 5 10 10")
contentspace.grid(column=0, row=0)

Where layout is one frame and contentspace would be the frame under the buttons to show dynamically-generated content, which would consist of grid items that would have their own independent columns and rows (like little independent HTML/CSS tables, basically). However, no matter what I did, whether it was adding buttons or labels, nothing would change or show up. I'd get no errors and the program would run, but nothing would happen.

Every time I googled this kind of thing, I got a lot of unrelated posts about Tkinter, so I figured I might make something specific here. I'm coding this by hand because IDEs make this computer keel over and die.

(and for those wondering, it's a program that chooses a random video game for me, taking into account prerequisite titles and already-played games.)

1 Answers1

0

Yes, tkinter supports "grids within grids", though that's a bit of a misnomer. Tkinter supports widgets inside of widgets. grid is simply the name of a method, it isn't a "thing".

If you create a frame, and don't give it a size or any children, it's size will default to one pixel. Unless you use the sticky option, it will be nearly or completely invisible.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685