please help to fix the script.
import tkinter
import sys
class mainMenu(tkinter.Frame):
def __init__(self, parent):
tkinter.Frame.__init__(self, parent)
self.pack(side = 'top', fill = 'x')
self.parent = parent
self.make_menu_bar()
def make_menu_bar(self):
menubar = tkinter.Menu(self.parent)
self.parent.config(menu = menubar)
file = tkinter.Menu(menubar, tearoff = False)
file.add_command(label = 'Quit', command = sys.exit())
menubar.add_cascade(label = 'File', menu = file)
class MainFrame(tkinter.Frame, mainMenu):
def __init__(self, parent):
tkinter.Frame.__init__(self, parent)
self.pack(side = 'top', fill = 'x', expand = 'yes')
self.parent = parent
self.make_elements()
def make_elements():
self.menu = TextPadMenu.__init__(self, parent)
root = MainFrame(tkinter.Tk())
root.mainloop()
the problem is that the class MainFrame can not inherit from: tkinter.Frame, mainMenu. error message is:
Traceback (most recent call last): File "C:\Python33\projects\TEXTPADS\textPad_OOP\q.py", line 22, in class MainFrame(tkinter.Frame, mainMenu): TypeError: Cannot create a consistent method resolution order (MRO) for bases Frame, mainMenu
MainFrameto inherit from Frame and mainMenu? mainMenu already inherits from Frame, so there's no need to inherit from Frame again.