[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]] ====2. Let the script return data==== The first step is to show a dialog window on your screen, then the next step is the interaction of the user with the gui. I think the easiest way is to divide guis into different groups. - Simple, Complex and Projects. **Simple** A simple dialog allows the user to give a response to a question/query on the screen: - Do you want to continue? - Please choose item in list - ... When the user click on the yes/no/cancel/ok-button the dialog exits and the script continues to evaluate the user input. Here is an example: %%(language-ref) export script=' ' I=$IFS; IFS="" for STATEMENTS in $(gtkdialog --program=script); do eval $STATEMENTS done IFS=$I [ $EXIT = sure ] && gxmessage 'You are sure' %% **Complex** For more complex dialogs, we want to keep the gui alive even if the user clicks on something, so using an EXIT value is not the right choice. Calling pre-defined functions from inside the gtkdialog gui is a handy way to do this. We must remember to export all functions before executing our gui. %%(language-ref) now () { date > /tmp/date } export -f now export script=' ENTRY_DATE cat /tmp/date ' gtkdialog -p script %% **Project** When your project grows and its complexity makes it hard to work with, it's time to consider another approach. Splitting code into several files might be much more usable when working with your code. Group familiar functions into one file... In this example, the function-file must be saved in /root/test to work. Instead of sending #### to an EXIT-variable, we send it to the file with the function 'now'. NOTE, that I don't use an ordinary function (like the previous example), but a case command instead. The benefits are faster loading of your app since it does not read your functions into memory, **but the greatest advantage is that you can edit the function while the gui is running.** The downside are slower execution of the function. Function file %%(language-ref) case $1 in -now) date > /tmp/date exit;; esac %% Main file %%(language-ref) export script=' ENTRY_DATE cat /tmp/date ' I=$IFS; IFS="" for STATEMENTS in $(gtkdialog -p script); do eval $STATEMENTS done IFS=$I %% ===@@**#%[[gtkdialogDocTips1|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips3|Next ❱❱❱]]#%**@@=== ---- ==Categories== CategoryGtkdialog