I'm trying out this simple piece of code. It was running earlier when I was using pack
, but when I changed it to grid
, nothing runs after the program is invoked from console. python.exe
keeps running as indicated in taskManager, but no GUI gets displayed. Please help.
from Tkinter import *
from tkFileDialog import askopenfilename
def fun():
fileName = askopenfilename(parent=top, title='Choose a file')
custName.set(fileName)
root = Tk()
root.geometry('400x150')
root.title('GUI App')
root.resizable(0,0)
top = Frame(root)
bottom = Frame(root)
top.pack(side=TOP)
label = Label(root, text = 'Enter the path upto the file name:')
label.grid(column=0,row=0,sticky='NW')
custName = StringVar(None)
filepath = Entry(root, width ='50', textvariable=custName)
filepath.grid(column=0,row=1,sticky='NW')
browse = Button(root, text="Browse", relief = 'raised', width=8, height=1, command=fun)
browse.grid(column=1,row=1,sticky='E')
quit_button = Button(root, text = 'Exit', relief = 'raised', command = top.quit)
quit_button.grid(column=1,row=3,sticky='SW')
mainloop()