Running into an issue trying to grid a framed object I created in a rudimentary paint program.
The instantiation code that gets the error is here:
from tkinter import *
from Menu import Menu
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self,master)
self.grid()
self.createWidgets()
def createWidgets(self):
#Imports each of the frames from the collection from the various widgets
menu=Menu()
menu.grid(row=0,column=0,columnspan=2)
app=Application()
app.master.title=('Sample Application')
app.mainloop()
The error I receive is related to the menu=Menu() operation and is:
TypeError: Menu() missing 1 required positional argument: 'Frame'
The Menu object is here:
from tkinter import *
import CommandStack
def Menu(Frame):
def __init__(self, master=None):
Frame.__init__(self,master)
self.createWidgets()
def createWidgets(self):
self.new=Button(self,command=CommandStack.new())
self.save=Button(self,command=CommandStack.save())
self.save.grid(row=0,column=1)
self.load=Button(self,command=CommandStack.load())
self.load.grid(row=0,column=2)
My confusion is how that positional error occurs. When I give the menu a frame (self), the grid method instead I get this error:
AttributeError: 'NoneType' object has no attribute 'grid'
I feel liking I'm missing a key part of working with frames, but I'm not sure what. Suggestions?
Menube a class or a function? You've defined it as a function (def) but implemented it like a class (__init__).