balthazarneveu / interactive_pipe

create interactive image processing pipeline with friendly sliders
The Unlicense
8 stars 1 forks source link

Add a few command line helpers --gui --fullscreen #33

Open balthazarneveu opened 1 year ago

balthazarneveu commented 1 year ago
def populate_parser_for_gui(parser=None):
    if parser is None:
        parser = argparse.ArgumentParser(description="Interactive Pipe Application")
    parser.add_argument(
        "--backend",
        choices=["mpl", "qt", "nb"],
        default="mpl",
        help="Backend to use: mpl (Matplotlib) or pyqt (PyQt)."
    )
    parser.add_argument(
        "--fullscreen",
        action="store_true",
        help="Start in fullscreen mode"
    )
    return parser

from typing import Tuple
from interactive_pipe.graphical.gui import InteractivePipeGUI
def gui_from_cli(parser=None) -> Tuple[InteractivePipeGUI, bool]:
    parser = populate_parser_for_gui(parser=parser)
    args = parser.parse_args()
    if args.backend == "mpl":
        from interactive_pipe.graphical.mpl_gui import InteractivePipeMatplotlib as InteractivePipeGui
        print("Using Matplotlib backend.")
    elif args.backend == "qt":
        from interactive_pipe.graphical.qt_gui import InteractivePipeQT as InteractivePipeGui
        print("Using PyQt backend.")
    elif args.backend == "nb":
        from interactive_pipe.graphical.nb_gui import InteractivePipeJupyter  as InteractivePipeGui
        print("Using PyQt backend.")
    return InteractivePipeGui, args.fullscreen