Closed hector-ps closed 2 years ago
Hi @hector-ps When your menu item needs to print output to screen, you'll need to halt that input at the end (or periodically with some form of pagination). A simple way to do this would be to add a "Press [Enter] to continue" prompt at the end of your processing using the PromptUtils class, like so:
from consolemenu import ConsoleMenu, Screen
from consolemenu.items import FunctionItem
from consolemenu.prompt_utils import PromptUtils
def print_report():
screen = Screen()
try:
screen.println("\n\nThis is my report.")
except Exception as e:
screen.println("Error printing report: %s" % e)
finally:
screen.println()
PromptUtils(screen).enter_to_continue()
def main():
menu = ConsoleMenu("My Menu")
report_menu_item = FunctionItem("Print Report", print_report)
menu.append_item(report_menu_item)
menu.show()
if __name__ == "__main__":
main()
When a function executed from a FunctionItem prints something in the console, the text is cut and mixed with the menu header. Can this be avoided?
An screenshot is attached.
Thank you in advance. Your work on this module is really useful.