Skip to content

Dialog not showing, help #4092

Closed Answered by falkoschindler
Leocrydis asked this question in Q&A
Discussion options

You must be logged in to vote

@Leocrydis I see. It boils down to the following example:

def show_dialog():
    with ui.dialog() as dialog:
        with ui.card():
            ui.label('Dialog')
    dialog.open()

with ui.button('Menu'):
    with ui.menu():
        ui.menu_item('Show dialog', on_click=show_dialog)

As discussed in #1852 (comment), the dialog is created inside the menu. So when clicking the menu item, which closes the menu, the dialog is hidden as well.

You can either create the dialog outside the click handler and re-use it, or explicitly create the dialog outside the menu:

def show_dialog():
    with ui.context.client.content:
        with ui.dialog() as dialog:
            with ui.card():
            …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Leocrydis
Comment options

Comment options

You must be logged in to vote
1 reply
@Leocrydis
Comment options

Answer selected by Leocrydis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants