I have a problem wherein I cannot create multiple distinct frames within a given frame. This is just a small chunk of my overall application but basically I've separated different Frames into classes and i call those classes depending on the situation.
What I am looking for is how to create 2 or more frames within this frame class. As of right now, the distinct frames aren't being created so when place them in a grid they overlap and replace each other. (i.e. frame2.label overlaps with frame1.label)
class MainPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
#First frame inside the current MainPage Window Frame
frame1 = Frame(self, bg = "red")
frame1.grid(row = 0, column = 0, sticky = W)
frame1.label = tk.Label(self, text="Main Page", font=SMALL_FONT)
frame1.label.grid(row = 0, column = 0, sticky = W)
itemScanNumber = StringVar()
frame1.EntryBox = ttk.Entry(self, textvariable = itemScanNumber)
frame1.EntryBox.grid(row = 0, column = 1, sticky = W)
print(itemScanNumber.get())
def printNumber():
print("Your Number: " + itemScanNumber.get())
return
frame1.button = ttk.Button(self, text = "CLICK ME FOR SCAN NUMBER!", command = printNumber)
frame1.button.grid(row = 0, column = 2, sticky = W)
frame1.button1 = ttk.Button(self, text = "CLICK ME!", command = lambda: controller.show_frame(MasterFilePage))
frame1.button1.grid(row = 0, column = 3, sticky = W)
#Second frame inside the current MainPage Window Frame
frame2 = Frame(self, bg = "blue")
frame2.grid(row = 1, column = 0, sticky = W)
frame2.label = tk.Label(self, text="Main Page2", font=SMALL_FONT)
frame2.label.grid(row = 0, column = 0, sticky = W)
frame1andframe1.labelin the main frame, and they are both in row 0, column 0. What are you trying to achieve with that, or did you intend to putframe1.labelinsideframe1? - Bryan Oakley