guiを作成しました。tkinterを使用しています。Python 3のtkinterの入出力。
ユーザーからの入力としてファイル名を受け取り、ファイルを開き、関数によって生成されたテキストのメッセージボックスを表示したいとします。
以下はコードですが、なぜこれが機能しないのか説明できますか?
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()
"name 'tksimpledialog' not defined"エラーが発生しました。
予想される結果が説明されていますが、エラーは何ですか? – dparoli
質問を編集しました。 – Yar