[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]] ====4.1 Set default status of radiobuttons, Comboboxes...==== A config file is a nice way to store the settings in your program. At next startup, it will show the settings like you left them last time. By default, gtkdialog always activates the first ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton ]]## and the first list-item for ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox ]]##. An easy way to use a config file is to run it like an ordinary bash-script, and include variable definitions in it. It is most common to keep config files in home directory as a hidden file ($HOME/.testrc). The file might look like this: %%(language-ref) COMBOBOX="item 3" ENTRY="default text" RADIOBUTTON1="false" RADIOBUTTON2="true" %% Now let's go to the main script. For the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/radiobutton ]]## and the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/entry ]]##, we set the #### tag to the corresponding variable in the config file. Since the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox ]]## doesn't support the #### tag, we need a workaround. We simply build the ##[[https://github.com/puppylinux-woof-CE/gtkdialog/wiki/combobox ]]## item-list so show our saved variable first. %%(language-ref) #in case no testc file (first run), build the file [ ! -s $HOME/.testrc ] && echo -e -n 'COMBOBOX="item 3"\nENTRY="default text"\nRADIOBUTTON1="false"\nRADIOBUTTON2="true"\n' > $HOME/.testrc . $HOME/.testrc #define combobox list items COMBOBOX_ITEMS="$COMBOBOX" #stored value should be first in list for I in 1 2 3 4; do COMBOBOX_ITEMS=`echo "$COMBOBOX_ITEMSitem $I"`; done export main=" COMBOBOX $COMBOBOX_ITEMS RADIOBUTTON1 $RADIOBUTTON1 RADIOBUTTON2 $RADIOBUTTON2 ENTRY $ENTRY " gtkdialog -p main > $HOME/.testrc %% The last codeline redirects output (variable values) to our config file instead of to the terminal. Note that line 2 starts with a dot. It makes a huge difference if you skip it. . $HOME/.config - run script as a childprocess as the main process. The variable values in the config file are reachable for the main script. $HOME/.config - run script as a new process as the main process. The variable values in the config file will NOT be reachable for the main script. ===@@**#%[[gtkdialogDocTips3|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips4.2|Next ❱❱❱]]#%**@@=== ---- ==Categories== CategoryGtkdialog