[Python] Keep selection of InputText after callback in DearPyGUI

Discussão em 'Python' iniciado por Stack, Junho 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a simple quiz program that consists of multiple questions. A snapshot of it looks like the following:

    with dpg.window(label="Quiz Window", pos=(150, 0), width=500, height=300, tag="Quiz Window", no_title_bar=True, no_resize=True, no_move=True):
    with dpg.group(horizontal=True):
    dpg.add_text("Question:")
    dpg.add_text(selector.selected_item[0], tag="Quiz Character", color=(0, 119, 200, 255))

    with dpg.group(horizontal=True):
    dpg.add_text("Answer:")
    dpg.add_input_text(tag="Quiz Input", width=300, callback=quiz_callback, on_enter=True)
    dpg.add_button(label="Submit", width=100, callback=quiz_callback)


    Let's say I selected the 'Quiz Input' InputText. Is there a way to keep my selection, or put it another way, keep inputting answers without the need to click on it again after the on_enter callback?

    full repo: https://github.com/thomasfung0119/hiragana_training

    Continue reading...

Compartilhe esta Página