Nov-28-2021, 11:13 PM
(This post was last modified: Nov-28-2021, 11:15 PM by Yoriz.
Edit Reason: removed unnecessary quote of previous post
)
Hi ghoul, the situation is the following:
the code in this case is the following:
the cursors '>' and '<' moves up and down to previous or following
menu item in according to the index "intro_index_selected" value, updating the print.
In this function for wait and catch the key pressed by the user i call the keyboard.wait() function.
When user press Enter key, thru the function "keyboard.add_hotkey('enter', intro_menu_key_enter)"
the relative function is called as shown below:
the 'enter' key thru keyboard.add_hotkey('enter', intro_menu_key_enter).
The login_form() was correctly called, but the first input was just "auto-validate" with empty value,
meanwhile is just possible to write in the second input.
If I choose another key instead of 'enter', it works properly ..
I've no idea where I could looking for the solution
the code in this case is the following:
def intro_menu(): intro_menu_create() keyboard.add_hotkey('up', intro_menu_key_up) keyboard.add_hotkey('down', intro_menu_key_down) keyboard.add_hotkey('space', intro_menu_key_enter) keyboard.wait() def intro_menu_create(): global intro_index_selected intro_menu = ["Accedi", "Registrati", "Esci"] cls() ascii_art() print("\n" * 3) print(" Accedi \ Registrati") for i in range(1, 4): print("{1} {0} {2}".format(intro_menu[i-1], ">" if intro_index_selected == i else " ", "<" if intro_index_selected == i else " ")) def intro_menu_key_up(): global intro_index_selected if intro_index_selected == 1: return intro_index_selected -= 1 intro_menu_create() def intro_menu_key_down(): global intro_index_selected if intro_index_selected == 3: return intro_index_selected += 1 intro_menu_create() def intro_menu_key_enter(): global intro_index_selected if intro_index_selected == 1: login_form() elif intro_index_selected == 2: registration_form() else: exit()In this "menu function" when user press 'up' or 'down' keys,
the cursors '>' and '<' moves up and down to previous or following
menu item in according to the index "intro_index_selected" value, updating the print.
In this function for wait and catch the key pressed by the user i call the keyboard.wait() function.
When user press Enter key, thru the function "keyboard.add_hotkey('enter', intro_menu_key_enter)"
the relative function is called as shown below:
def intro_menu_key_enter(): global intro_index_selected if intro_index_selected == 1: login_form() elif intro_index_selected == 2: registration_form() else: exit()Now the problem exist when i call login_form() after have obtained
the 'enter' key thru keyboard.add_hotkey('enter', intro_menu_key_enter).
The login_form() was correctly called, but the first input was just "auto-validate" with empty value,
meanwhile is just possible to write in the second input.
If I choose another key instead of 'enter', it works properly ..
I've no idea where I could looking for the solution