Python Forum
[Tkinter] Entry problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Entry problem
#1
Hi,

I have an app with a simple Tkinter GUI. It has an Entry box, where the user can type something or not.
entryText1 = Entry(root, width = 65, font=myFontBold,bg='yellow')
entryText1.grid(row=1,column=0,columnspan=2,padx=20,pady=10)
entryText1.insert(0,'Remark:')
entryText1.config(state=NORMAL)
The whole app works fine, but i cannot get focus on the entry box, and therefore it is not possible to enter text.

I did some research and suggested wordkarounds are:
1) click outside the app window, then in the entry box-> that works, but won't win any prizes.
2) use root.overrideredirect(True): does not work, and takes away all window controls.
3) Setting focus on the Entry is no good either

Any ideas on what I could try next?
thx,
Paul

Edit: i found somewhere that a fileopendialog can cause that phenomenon.
The trick is to insert root.update_idletasks() just before. It works!
Reply
#2
please show enough of a code snippet so that it can be run.
Reply
#3
try:
entryText1.focus()
you can also:
entryText1.bind('<Return>', (lambda event:your_function()))
Reply
#4
As I'm sure you know, your example, even with the required tkinter trappings, does not display the behavior you describe. If you click on an Entry widget the widget gets the keyboard focus and you can type in the widget. If yours is not doing that there must be some reason, and you are not providing any of the code that could be the reason why your entry behaves this way.

Does the Entry work if you run this program?
from tkinter import *

root = Tk()
entryText1 = Entry(root, width = 65, bg='yellow')
entryText1.grid(row=0,column=0,padx=20,pady=10)
entryText1.insert(0,'Remark:')
entryText1.config(state=NORMAL)
If so, Entry works and the problem is elsewhere. We need more info about the elsewhere. How are you using the Entry. Can you provide more of the surrounding code? Does this problem happen all the time, or does the entry work for a while and then stop working?
Reply
#5
I'm sure you all want to help, but you also don't want me to publish 975 lines of code.
I was just looking for somebody who recognises the symptoms.

I found somebody, and edited my post before anybody responded to it here.
FYI the problem is solved.

thx,
Paul
Reply
#6
What was the cause of the problem?

975 lines of code is probably not required to demonstrate the problem. But if it is 975 lines that I can copy/paste and run and see the problem, I prefer that to 5 lines of code that do nothing to demonstrate the problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with setting variable within a Entry validatecommand kenwatts275 1 1,853 Mar-31-2020, 01:53 AM
Last Post: deanhystad
  Grid data entry problem kenwatts275 3 2,246 Mar-22-2020, 03:13 PM
Last Post: kenwatts275
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,420 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,452 Mar-18-2019, 05:36 PM
Last Post: woooee
  [Tkinter] Problem reading entry box in thread LeeMadeux 2 3,300 Jan-17-2018, 03:15 PM
Last Post: LeeMadeux

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020