I have been creating a gui using tkinter.
I want to receive a filename as input from the user, open the file and display a message box with text generated by a function.
Below is the code, can someone explain why this is not working?
import tkinter as tk
import csv
import tkinter.simpledialog
import tkinter.messagebox
from tkinter import ttk
file=tkinter.simpledialog.askstring("File: ","Enter your file name")
with open(file, 'r') as f: #this line reads the file
reader = csv.reader(f, delimiter=',')
output=values
def values(): #And this is the function
print("Some text")#which should return whatever info is inside 'print' function
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
button = ttk.Button(self, text="Submit", #I prefer using the button but any other way will do
command=tkmessagebox.showinfo("Results",output))
button.pack()
I get "name 'tksimpledialog' is not defined" error.