How to create a menu from a file, python3 + Tkinter?

Good day, how you can create a menu from a file by reading it line by line
#!/usr/bin/python
# -*- coding: utf-8 -*-
import webbrowser
from Tkinter import *
from Tkinter import Tk, Frame, Menu
file = open(data, 'r')
lines = file.readlines()
index = -1
def textChange(self):
 self.index -= 1
self.test.setText(self.lines[self.index])


class Example(Frame):
 def __init__(self, parent):
 Frame.__init__(self, parent)
 self.parent = parent
self.initUI()

 def initUI(self):
 self.parent.title("Name")

 menubar = Menu(self.parent)
self.parent.config(menu=menubar)
 fileMenu = Menu(menubar)
 submenu = Menu(fileMenu)
 menusubmenu = Menu(submenu)
 fileMenu.add_cascade(label='menu item', menu=submenu, underline=1)
 submenu.add_cascade(label='sub-menus from file', menu=menusubmenu, underline=0)
 menusubmenu.add_command(label="actions 1", command= lambda: webbrowser.open('http://', new=2) )
 menusubmenu.add_command(label="Действие2", command= lambda: textChange)



fileMenu.add_separator()
 fileMenu.add_command(label="Exit", underline=0, command=self.onExit)
 menubar.add_cascade(label="File", underline=0, menu=fileMenu)

 def onExit(self):
self.quit()

def main():
 root = Tk()
root.geometry("750x350+300+300")
 app = Example(root)
root.mainloop()


if __name__ == '__main__':
 main()
March 12th 20 at 08:07
1 answer
March 12th 20 at 08:09
what is not working?
not unload from the menu from a file that each line was a menu item - ismael64 commented on March 12th 20 at 08:12

Find more questions by tags TkinterPython