You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having trouble figuring out where/how to call FunctionItem.get_return() so that I can display the return data while a ConsoleMenu is running. Here's an example script to help explain what I'm trying to do.
fromconsolemenuimport*fromconsolemenu.itemsimport*defcommand_1():
print("Command 1 ran")
return"Command 1 ran"defcommand_2():
print("Command 2 ran")
return"Command 2 ran"defmain():
menu=ConsoleMenu("Root Menu", "This is the Root Menu Subtitle")
# Create a menu item that calls a functionfunction_item_1=FunctionItem("Command 1", command_1)
function_item_2=FunctionItem("Command 2", command_2)
menu.append_item(function_item_1)
menu.append_item(function_item_2)
# Show the menumenu.show()
print(function_item_1.get_return())
print(function_item_2.get_return())
if__name__=="__main__":
main()
With this approach, the text printed to the screen in command_1() and command_2() gets overwritten immediately when the menu redraws. The get_return() prints after menu.show() don't appear until after exiting the menu, which makes sense since menu.show() is blocking. So I have two questions:
Is there a way, using console-menu, to delay redrawing the menu after a FunctionItem's function is called (maybe until another keyboard/enter input) so that anything printed in the function doesn't get overwritten immediately?
Is there a way to do the same as 1 but using function_item_*.get_return() outside of the functions themselves? I'm assuming I need to use another thread but I'm not sure.
Thanks!
The text was updated successfully, but these errors were encountered:
I'm having trouble figuring out where/how to call
FunctionItem.get_return()
so that I can display the return data while a ConsoleMenu is running. Here's an example script to help explain what I'm trying to do.With this approach, the text printed to the screen in
command_1()
andcommand_2()
gets overwritten immediately when the menu redraws. Theget_return()
prints aftermenu.show()
don't appear until after exiting the menu, which makes sense sincemenu.show()
is blocking. So I have two questions:Is there a way, using console-menu, to delay redrawing the menu after a
FunctionItem
's function is called (maybe until another keyboard/enter input) so that anything printed in the function doesn't get overwritten immediately?Is there a way to do the same as 1 but using
function_item_*.get_return()
outside of the functions themselves? I'm assuming I need to use another thread but I'm not sure.Thanks!
The text was updated successfully, but these errors were encountered: