I am trying to make a browse button for a GUI to test for accuracy. The button come in perfectly as well as the entry widget. I use tkFileDialog.askopenfilename() which opens the dialog box and allows me to select a file.
When I click open though nothing no text shows up in the entry widget though it would seem that the script is recognizing a file in the widget. I don't know how the text became invisible.
I have done a fair amount of research and tweaking to get this to work and nothing I try on my own or from the research seems to work. It is probably a quick fix and I am over thinking it.
import tkFileDialog
from Tkinter import *
LARGE_FONT = ("Times New Roman", 18)
FONT = ("Times New Roman", 12)
background = "#A8A8A8"
def set_text(text, File):
File.delete(0, "end")
File.insert(0, text)
return
class AccuracyAssessmentApp:
#The main function
def __init__(self, parent=Tk()):
self.mainWindow = (parent)
self.mainWindow.title("Accuracy Assessment")
self.mainWindow.geometry("1000x700")
self.make_txt()
self.browse()
#Set the text for the main window
def make_txt(self):
self.text = Text(self.mainWindow, width = 80, height = 40, background = background)
self.text.pack(expand = TRUE, fill = BOTH)
def browse(self):
self.inputRaster = Entry(self.mainWindow, width=70).place(x=5,y=150)
Button(self.mainWindow, text="Input", command=lambda: set_text(tkFileDialog.askopenfilename(), self.inputRaster)).place(x=575,y=150)
app = AccuracyAssessmentApp()
app.mainWindow.mainloop()