So, basically I'm trying to make a control menu in my tkinter app, and make a button open a file and save it to a variable. I want to see if I can do that using only lambda functions instead of normal functions (as in defining functions). Is there any way I can do that with the given code? (Thanks very much.)
from tkinter.filedialog import askopenfilename
import tkextra as tke
import os
root = tk.Tk()
controlMenuBox = tk.Menu(root)
openFile = lambda initialDirectory, title, fileTypes : \
askopenfilename(initialdir=initialDirectory, title=title, filetypes=fileTypes)
fileMen = tk.Menu(controlMenuBox, tearoff=0)
controlMenuBox.add_cascade(label='File', menu=fileMen)
fileMen.add_command(label='Open File',
command=lambda: openFile("/", "Open File", (("Text files", "*.txt"), ("all files", "*.*"))))
homeMenu = tk.Canvas(root, width=800, height=600, bg="#fff7e8")
homeMenu.pack()
root.config(menu = controlMenuBox)
root.mainloop()