{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Dialog\n\nThe dialog is created from a QDialog, designed in QtDesigner.\nThe dialog already has OK and Cancel buttons whose clicked\nsignal is connected with the accept and reject slot of the\ndialog. If you show the dialog in a modal way, you can then\nobtain the result (if OK or Cancel has been clicked).\nUse deleteOnClose=true such in order to close the dialog once\nthe user pressed OK or Cancel.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import ui\n\n\n\ndialog = ui(\"dialog.ui\", ui.TYPEDIALOG)\nprint(\"Result of the dialog:\", dialog.show(1)) # show a modal dialog" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dialog created from widget. In this case, no terminating buttons\nare visible. The behaviour is then similar to a main window without\nthe minimize or maximize buttons\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "dialog_widget = ui(\"widget.ui\", ui.TYPEDIALOG)\ndialog_widget.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the dialog should be created from a widget, you can automatically let\nitom place buttons at the right or bottom side of the widget. Define the\ntitle and the role of each button using a dictionary. The roles are taken\nfrom Qt (``QDialogButtonBox::ButtonRole``)\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "dialog_widget_buttonbar = ui(\n \"widget.ui\",\n ui.TYPEDIALOG,\n ui.BUTTONBAR_VERTICAL,\n {\"AcceptRole\": \"OK\", \"RejectRole\": \"Cancel\"},\n)\nprint(\"Result of the dialog:\", dialog_widget_buttonbar.show(1))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }