0

I'm tring to make a console app, so I want to detect when the user uses the "Enter" key, but it doesn't call my function when it's supposed to be.. Here's the code

CommandBar = Text(WINDOW, height="500", width="1000", bg="Black", fg="green", insertbackground="green")


WINDOW.geometry("1000x500")
WINDOW.title("SCP_OS:/Unknown User*")
WINDOW.configure(bg="black")



def ResetCommandBar(CommandEntered):
    CommandBar.insert(END, "SCP_OS:/Unkown_User : ")
    print(123)

WINDOW.bind("<Enter>", ResetCommandBar(CommandBar.get("1.0", "end -1c")))

CommandBar.pack()

WINDOW.mainloop()
  • 1
    there isn't any prints of "123" – julian 2_1 Sep 12 '22 at 16:50
  • 1
    Change `ResetCommandBar(...)` to `lambda e: ResetCommandBar()`. Also the binding for the enter key is ""`, not `""` – TheLizzard Sep 12 '22 at 16:51
  • 1
    Does this answer your question? [Why is my Button's command executed immediately when I create the Button, and not when I click it?](https://stackoverflow.com/questions/5767228/why-is-my-buttons-command-executed-immediately-when-i-create-the-button-and-no) It's not exactly the same but still the same mistake and same solution. – TheLizzard Sep 12 '22 at 16:52

0 Answers0