Python Forum
[Tkinter] cannot type in textbox - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] cannot type in textbox (/thread-11816.html)



cannot type in textbox - msteffes - Jul-26-2018

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()



RE: cannot type in textbox - woooee - Jul-27-2018

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.


RE: cannot type in textbox - msteffes - Jul-28-2018

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.