Python Forum

Full Version: cannot type in textbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello All,
I am new to Python and have found my first head scratcher. I expect to find a have stumbled into some rookie mistake.

The below code creates a texbox that I can enter text in, highlight, copy ...
if I un-comment the file dialog portion of code the text box will no longer accept keyboard entry.
I have replicated this in 3.7 using Idle and 3.6 using Thonny.

What am I missing, or doing wrong.

from tkinter import filedialog
from tkinter import *


#build form
frmMain = Tk()


Tb1 = Text(frmMain,bd=10,height=12)
Tb1.grid(row=0,column=0,padx=10,pady=10,sticky=W+E)



##frmMain.filename =  filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("CSV files","*.csv"),("all files","*.*")))
##NameOfFile = frmMain.filename
##f = open(NameOfFile,"r")  

##f.close


frmMain.mainloop()
The computer can only run one thing at a time, unless you specifically program it to do multiple things. Therefor, while the filedialog is running you can not do anything else until it has returned to the calling program.
It is not clear to me how to correct this. Can anyone provide a basic example of using a file dialog as part of a larger form.