I am using ipyvutify trying to code great GUIs. It looks fantastic but a bit hard for someone who had never did HTML & CSS.
The following is a complete code that generates a dialog floating when clicking "OPEN DIALOG" button.
I would like to unterstand the functioning of opening and closing floating dialogs using ipyvuetify and with the following code I can not figure it out even if the code works (deficiently).
The GOAL is to open a dialog with a button and having a CLOSE button inside the dialog as well (together with other buttons)
import ipyvuetify as v
lorum_ipsum= 'loren loren'
#oepn dialog:
v_btn_OTHER = v.Btn(class_='mx-2 light-blue darken-1', children=['OTHER'])
def on_click_v_btn_OPEN (widget, event, data):
exampledialog.value = True
pass
v_btn_OPEN.on_event('click', on_click_v_btn_OPEN)
# CLOSE BUTTON INSIDE THE DIALOG
v_btn_CLOSE = v.Btn(class_='mx-2 light-blue darken-1', children=['CLOSE'])
def on_click_v_btn_CLOSE (widget, event, data):
exampledialog.value = False
v_btn_CLOSE.on_event('click', on_click_v_btn_CLOSE)
# ACTION BUTTON INSIDE THE DIALOG
v_btn_OTHER = v.Btn(class_='mx-2 light-blue darken-1', children=['OTHER'])
def on_click_v_btn_OTHER (widget, event, data):
# code to open facebook.com in a new tab
pass
v_btn_OTHER.on_event('click', on_click_v_btn_OTHER)
# THE DIALOG
exampledialog = v.Dialog(width='500',
v_slots=[{
'name': 'activator',
'variable': 'x',
'children': v.Btn(v_on='x.on', color='success', dark=True, children=[
'OTHER dialog'
]),
}],
children=[
v.Card(children=[
v.CardTitle(class_='headline gray lighten-2', primary_title=True, children=[
"Lorem ipsum"
]),
v.CardText(children=[
lorum_ipsum,
v.TextField(label='Label', placeholder='Placeholder'),
v_btn_CLOSE,
v_btn_OTHER,
]),
])
])
# VISUALIZATION
display(v.Layout(children=[v_btn_OPEN,exampledialog]))
If you paste the above code in one of your cells you will realise the follwoing strange behavior that I would like to understand.
If you dont display exampledialog in the VISUALIZATION PART then the OTHER button would not work. ONLY if exampledialog is part of the children of Layout the button is working. Besides the button of the dialog itself disappears once is run the first time.
This is a really strange thing. Can someone give an explanation.
And the general question is how do you open and close a dialog from a button outside the dialog. dialog.value=True does not really seems to work