How to use the imgui.menu_item function in imgui

To help you get started, we’ve selected a few imgui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github swistakm / pyimgui / doc / examples / combined.py View on Github external
def on_frame():
    if imgui.begin_main_menu_bar():
        if imgui.begin_menu("File", True):
            clicked_quit, selected_quit = imgui.menu_item(
                "Quit", 'Cmd+Q', False, True
            )
            if clicked_quit:
                exit(1)
            imgui.end_menu()
        imgui.end_main_menu_bar()
    imgui.show_test_window()
    imgui.begin("Custom window", True)
    imgui.text("Bar")
    imgui.text_colored("Eggs", 0.2, 1., 0.)
    imgui.end()
github swistakm / pyimgui / doc / examples / pygame_.py View on Github external
renderer = PygameRenderer()

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            renderer.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()
github swistakm / pyimgui / doc / examples / pyglet_.py View on Github external
def update(dt):
        imgui.new_frame()
        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()
github swistakm / pyimgui / doc / examples / pysdl2.py View on Github external
running = True
    event = SDL_Event()
    while running:
        while SDL_PollEvent(ctypes.byref(event)) != 0:
            if event.type == SDL_QUIT:
                running = False
                break
            renderer.process_event(event)
        renderer.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()
github swistakm / pyimgui / doc / examples / cocos2d.py View on Github external
def draw(self, *args, **kwargs):
        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()
github christopherdumas / atomicdatabase / AtomicDatabase / __main__.py View on Github external
clicked_save_as, selected_save_as = imgui.menu_item(
            "Save As...",
        )

        if clicked_save_as:
            show_save_as = True

        clicked_load, selected_load = imgui.menu_item(
            "Load File...",
        )

        if clicked_load:
            show_load_db = True

        clicked_load_example, selected_load_example = imgui.menu_item(
            "Load Example Database",
        )

        if clicked_load_example:
            DB.load_examples()

        clicked_quit, selected_quit = imgui.menu_item(
            "Quit", 'Cmd+Q', False, True
        )

        if clicked_quit:
            exit(1)

        imgui.end_menu()
    return show_save_as, show_load_db
github swistakm / pyimgui / doc / examples / glfw3.py View on Github external
def main():
    window = impl_glfw_init()
    impl = GlfwRenderer(window)

    while not glfw.window_should_close(window):
        glfw.poll_events()
        impl.process_inputs()

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()
github christopherdumas / atomicdatabase / AtomicDatabase / __main__.py View on Github external
def draw_file_menu(show_save_as, show_load_db):
    if imgui.begin_menu("File", True):
        clicked_save, selected_save = imgui.menu_item(
            "Save",
        )

        if clicked_save:
            eav.save_to_file(DB, database_name)

        clicked_save_as, selected_save_as = imgui.menu_item(
            "Save As...",
        )

        if clicked_save_as:
            show_save_as = True

        clicked_load, selected_load = imgui.menu_item(
            "Load File...",
        )
github christopherdumas / atomicdatabase / AtomicDatabase / __main__.py View on Github external
if event.type == SDL_QUIT:
                running = False
                break
            renderer.process_event(event)
        renderer.process_inputs()

        imgui.new_frame()
        push_settings()

        if imgui.begin_main_menu_bar():
            (show_save_as, show_load_db) = draw_file_menu(show_save_as, show_load_db)

            # draw window menu
            if imgui.begin_menu("Window", True):
                for key in SHOW_VARS:
                    _, SHOW_VARS[key] = imgui.menu_item(
                        "Show " + key.title() + " View", selected=SHOW_VARS[key]
                    )

                imgui.end_menu()

            imgui.end_main_menu_bar()

        # if the menu triggered a popup, keep the popup on until we say otherwise
        if show_load_db:
            imgui.open_popup("load-db")
        if show_save_as:
            imgui.open_popup("save-as")


        # draw menu popups
        new_name = draw_ok_cancel_popup("save-as", "File Name to Save As:")