aegirhall / console-menu

A simple Python menu system for building terminal user interfaces.
MIT License
365 stars 58 forks source link

Unclear How to Retrieve Return Value from Selection SubMenu after calling Show() on Main Menu. #51

Closed JulianPitney closed 4 years ago

JulianPitney commented 4 years ago
lightsheetScans = ["scan1", 'scan2', 'scan3']
currentScanSelectionIndex = None`

mainMenu = ConsoleMenu(mainMenuTitle, mainMenuSubTitle, prologue_text=mainMenuPrologue, epilogue_text=mainMenuEpilogue)
lightsheetMenu = ConsoleMenu(lightsheetMenuTitle, prologue_text=lightsheetPrologue, epilogue_text=lightsheetEpilogue)
lightsheetItem = SubmenuItem("Lightsheet Data", lightsheetMenu, mainMenu)

openScanMenu = SelectionMenu(lightsheetScans, "Select a Scan To Open", prologue_text="Opening a scan opens the metadata and a thumbnail of the stitched scan for the user to view.")
openScanMenuItem = SubmenuItem("Open Scan", openScanMenu, lightsheetMenu)

mainMenu.append_item(lightsheetItem)
lightsheetMenu.append_item(openScanMenuItem)
mainMenu.show()

The menu rendering and navigation all work correctly, however I'm not sure what the best way to retrieve the index returned by openScanMenu. Do I need to manage the start() and join() functions myself, or is there a way to retrieve it while only having to call show() once?

Edit: I'd like to make it clear that I need to get the return value of openScanMenu.get_selection() in the main thread where mainMenu.show() is called.