I'm trying to put my 3 buttons inside the gray frame (labeled mainframe), even though I put the parent of the buttons as the frame.
import tkinter
class theUI():
def __init__(self):
self.root = tkinter.Tk()
self.root.geometry("500x600")
self.mainframe = tkinter.Frame(self.root, height=300, width=400, bg="gray").pack(side="left")
tkinter.Button(master=self.mainframe, text="Rock").pack(side="left")
tkinter.Button(master=self.mainframe, text="Paper").pack()
tkinter.Button(master=self.mainframe, text="Scissors").pack(side="right")
self.root.mainloop()
game = theUI()
I tried using pack and grid but they both gave me the same issue. I just started using tkinter so I'm still learning how the widgets work.
Note that
self.mainframe
isNone
because it is the result of.pack(...)
. So the buttons will be children of root window because their parent isNone
.You need to separate the following line:
into two lines: