I am trying to create a UI using Tkinter that uses LabelFrames and I want to lay them out in a grid. However, they are only appearing when I use the .pack method. I'm not sure if this is because they are a container more than a widget but if someone could help me out that would be great.
from tkinter import ttk
from tkinter import *
from tkinter.ttk import *
class MainWindow(tkinter.Tk):
def __init__(self, parent):
tkinter.Tk.__init__(self, parent)
self.parent = parent
self.initialize()
def initialize(self):
self.geometry("788x594")
self.resizable(False, False)
self.title("Testing UI")
Btn = Button(self, text = "Test")
Btn.grid(column = 0, row = 1)
testFrame = LabelFrame(self, text = "Test")
testFrame.grid(column = 0, row = 2, sticky="EW")
if __name__ == "__main__":
app = MainWindow(None)
app.mainloop()
And this is the output I get Output
CodePudding user response:
The frame is appearing. Because there's nothing in the frame, and because you haven't set a size for the frame, it is only 1 pixel wide and 1 pixel tall.