-2

I wanna enter a number in the following code with enter and not with the button. It works with the button but i don't know how to give in the input with pressing enter and not the button

    def lego():
        if userinput.get() == '3':
            if filesd['jdisk']['status'] == 'true':
                print('Laufwerk J: ist bereits belegt.')
            else:
                os.system('net use J: \\\\testpath\\testpath')
                filesd['jdisk']['status'] = 'true'

    luserinput = Label(root, text="Zeichen eingeben um Python-Befehl auszuführen:")
    userinput = Entry(root)

    lbutton = Button(root, text="Search", command=lego)
Joel S.
  • 64
  • 7

1 Answers1

0

Thanks to furas:

userinput.bind('<Return>', lego)

And you need:

def lego(event):

Joel S.
  • 64
  • 7
  • 1
    BTW: If you will use `Enter` and `Button` then you will need `event=None` in `def logo(event=None)` to work with both. – furas Nov 22 '19 at 09:39