Open dovydasz opened 1 year ago
Hello @dovydasz ,
Here is an example for you:
import remi.gui as gui
from remi import start, App
class MyApp(App):
def main(self):
# creating a container VBox type, vertical (you can use also HBox or Widget)
self.main_container = gui.VBox(width=300, height=200, style={'margin': '0px auto'})
bt = gui.Button("Open dialog")
bt.onclick.do(self.on_bt_clicked)
self.main_container.append(bt)
# returning the root widget
return self.main_container
def on_bt_clicked(self, emitter): #show dialog and focus confirm_button
self.dialog = gui.GenericDialog(title='Dialog Box', message='Ok button is focused, you can type Enter.', width='500px')
self.dialog.confirm_dialog.do(self.dialog_confirm)
self.dialog.show(self)
self.execute_javascript(f"document.getElementById('{self.dialog.children['buttons_container'].children['confirm_button'].identifier}').focus();")
def dialog_confirm(self, emitter):
print("dialog confirmed")
if __name__ == "__main__":
# starts the webserver
start(MyApp, address='0.0.0.0', port=0, start_browser=True)
In this example, after showing the dialog we trigger the focus on the confirm_button.
Kind Regards ;-)
Can I call GenericDialog confirm function by pressing Enter key? Like we can do with InputDialog.
Thanks in advance!