0
Python初心者は、ここに。私は、TkInter関数から値を返すという話題に関してたくさんの質問があることに気付きましたが、解決策のどれもが私の問題を解決してくれないようです。ボタン付きTkInterエントリからの戻り値
私は正常にprint
self.e1path
からシェルにgetPath.submit
から、しかし私はreturn
私のコードの残りの部分にできません。クラス外でprintステートメントを使用して、CSVパスが正常に返されたかどうかをテストしています。
from tkinter import *
import tkinter as tk
class getPath(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.label1 = tk.Label(self, text="CSV Path").grid(row=0, column=0)
self.e1 = tk.Entry(self, width=50)
self.e1Grid = self.e1.grid(row=0, column=1)
self.browse = tk.Button(self, text='Browse', command=self.getCSV).grid(row=0, column=2)
self.submit = tk.Button(self, text='Submit', command=self.submit).grid(row=1, column=1)
def getCSV(self):
self.fileName = filedialog.askopenfilename(filetypes = (('Comma Separated Values', '*.csv'), ('All Files', '*.*')), title = "Choose a CSV File")
self.e1.insert(10, self.fileName)
def submit(self):
self.e1Path = self.e1.get()
return self.e1Path
app = getPath()
app.mainloop()
print(app)
私はあなたの質問に答えましたか? –