D
DevynCJohnson
Guest
Some shell script writers may want to add a GUI interface to their script. As most people may know, various options are available such as Zenity, KDialog, Dialog, XDialog, etc. Perhaps, some developers may not be satisfied with those choices. Thankfully, there is yet another choice - EZwin. EZwin is a Python3-based program that provides an easy way to provide GTK3 windows to a script (like Zenity).
Ezwin can be downloaded for free (LGPLv3) at http://dcjtech.info/topic/ezwin-easy-windows/. Ezwin was made by the author of this article (Devyn Collier Johnson <[email protected]>).
Ezwin also functions as a library with a Python3 API. Thus, Python3 developers can use these windows in their Python programs.
To invoke ezwin, type ezwin [FLAG] [ARGUMENTS]. Like other command-line programs, the "-h" and "-v" flags display the help and version information, respectively. EZwin provides various window types.
Info
To make an information dialog, type
This dialog (and the ones similar to it) can be used to graphically display the output of a command or script. The below command is an example.
Message
To make a message dialog, type
Warning
To make a warning dialog, type
Error
To make an error dialog, type
Update
To make an update dialog, type
Security
To make a security dialog, type
Question Dialog with Yes/No
To ask a question, use the below code which provides the choices "Yes" and "No". The return value (output) of this command is "True" or "False", respectively. The returned output provides a way for the script to know what the user chose.
Question Dialog with Yes/No/Close
To ask a question, use the below code which provides the choices "Yes", "No", and "Close". The return value (output) of this command is "True", "False", or "Close", respectively. The returned output provides a way for the script to know what the user chose.
Question Dialog with Yes/No/Quit
To ask a question, use the below code which provides the choices "Yes", "No", and "Quit". The return value (output) of this command is "True", "False", or "Quit", respectively. The returned output provides a way for the script to know what the user chose.
Question Dialog with Yes/No/Cancel
To ask a question, use the below code which provides the choices "Yes", "No", and "Cancel". The return value (output) of this command is "True", "False", or "Cancel", respectively. The returned output provides a way for the script to know what the user chose.
Input Text Dialog
A script can accept input from the user using this dialog. The below command returns the typed input.
Input Text Dialog with 'Cancel'
A script can accept input from the user using this dialog. The below command returns the typed input, or nothing if "Cancel" is clicked.
Password Dialog
A script can accept input from the user using this dialog. The below command returns the typed input.
Password Dialog with 'Cancel'
A script can accept input from the user using this dialog. The below command returns the typed input, or nothing if "Cancel" is clicked.
Color
Using the below code, a user can select a color and the script can get the color recipe. The returned data (output) may look something like "Gdk.RGBA(red=0.953333, green=0.932425, blue=0.108044, alpha=0.915194)". "None" is returned if the window is close.
File Chooser
The file chooser dialog provides a way for users to select a file. The below code returns something like "['file:///media/collier/PROGRAMMING/pybooster/ezwin/filech.glade']", if the user chooses a file. If "Cancel" is clicked, then "Cancel" is returned. Append the "-h" parameter to display hidden files. Because the "--file" flag is used, the program understands that the "-h" does not mean "help". If the user may select multiple files, then append the "-m" parameter. The initial path of the file chooser can be set using the "--path" parameter followed by the path. However, this flag must be the last flag used.
Directory Chooser
The directory chooser dialog provides a way for users to select a directory. The below code returns something like "file:///media/collier/PROGRAMMING/pybooster/ezwin", if the user chooses a directory. If "Cancel" is clicked, then "Cancel" is returned. Append the "-h" parameter to display hidden files. Because the "--dir" flag is used, the program understands that the "-h" does not mean "help". If the user may select multiple directories, then append the "-m" parameter. The initial path of the directory chooser can be set using the "--path" parameter followed by the path. However, this flag must be the last flag used.
The various EZwin windows can be used together. For instance, the recipe for a chosen color can be saved to a file using the file chooser. An example command is seen below. The "--save" parameter is used to indicate that the file chooser will save a file. The "-n" means the file name rather than the URI will be returned. "--str" will make the file's pathname be returned as a string rather than a list (in square brackets).
Further Reading
Dialog - http://www.linux.org/threads/dialog-another-gui-for-scripts.5900/
KDialog - http://www.linux.org/threads/kdialog-kde-gui-for-scripts.5815/
Zenity - http://www.linux.org/threads/zenity-gui-for-shell-scripts.5567/
Ezwin can be downloaded for free (LGPLv3) at http://dcjtech.info/topic/ezwin-easy-windows/. Ezwin was made by the author of this article (Devyn Collier Johnson <[email protected]>).
Ezwin also functions as a library with a Python3 API. Thus, Python3 developers can use these windows in their Python programs.
To invoke ezwin, type ezwin [FLAG] [ARGUMENTS]. Like other command-line programs, the "-h" and "-v" flags display the help and version information, respectively. EZwin provides various window types.
Info
To make an information dialog, type
Code:
ezwin -i "This is a message."
Code:
ezwin -i $(whoami; echo '\n'; date)
Message
To make a message dialog, type
Code:
ezwin -m "This is a message."
Warning
To make a warning dialog, type
Code:
ezwin -w "This is a warning."
Error
To make an error dialog, type
Code:
ezwin --err "This is an error."
Update
To make an update dialog, type
Code:
ezwin -u "This is an update message/warning."
Security
To make a security dialog, type
Code:
ezwin -s "This is a security message/warning."
Question Dialog with Yes/No
To ask a question, use the below code which provides the choices "Yes" and "No". The return value (output) of this command is "True" or "False", respectively. The returned output provides a way for the script to know what the user chose.
Code:
ezwin -q "Is this a hard question?"
Question Dialog with Yes/No/Close
To ask a question, use the below code which provides the choices "Yes", "No", and "Close". The return value (output) of this command is "True", "False", or "Close", respectively. The returned output provides a way for the script to know what the user chose.
Code:
ezwin --ync "Is this a hard question?"
Question Dialog with Yes/No/Quit
To ask a question, use the below code which provides the choices "Yes", "No", and "Quit". The return value (output) of this command is "True", "False", or "Quit", respectively. The returned output provides a way for the script to know what the user chose.
Code:
ezwin --ynq "Is this a hard question?"
Question Dialog with Yes/No/Cancel
To ask a question, use the below code which provides the choices "Yes", "No", and "Cancel". The return value (output) of this command is "True", "False", or "Cancel", respectively. The returned output provides a way for the script to know what the user chose.
Code:
ezwin -c "Is this a hard question?"
Input Text Dialog
A script can accept input from the user using this dialog. The below command returns the typed input.
Code:
ezwin -t "Type something."
Input Text Dialog with 'Cancel'
A script can accept input from the user using this dialog. The below command returns the typed input, or nothing if "Cancel" is clicked.
Code:
ezwin --tc "Type something."
Password Dialog
A script can accept input from the user using this dialog. The below command returns the typed input.
Code:
ezwin -p "Tell me your secrets."
Password Dialog with 'Cancel'
A script can accept input from the user using this dialog. The below command returns the typed input, or nothing if "Cancel" is clicked.
Code:
ezwin --pc "Tell me your secrets."
Color
Using the below code, a user can select a color and the script can get the color recipe. The returned data (output) may look something like "Gdk.RGBA(red=0.953333, green=0.932425, blue=0.108044, alpha=0.915194)". "None" is returned if the window is close.
Code:
ezwin --color
File Chooser
The file chooser dialog provides a way for users to select a file. The below code returns something like "['file:///media/collier/PROGRAMMING/pybooster/ezwin/filech.glade']", if the user chooses a file. If "Cancel" is clicked, then "Cancel" is returned. Append the "-h" parameter to display hidden files. Because the "--file" flag is used, the program understands that the "-h" does not mean "help". If the user may select multiple files, then append the "-m" parameter. The initial path of the file chooser can be set using the "--path" parameter followed by the path. However, this flag must be the last flag used.
Code:
ezwin --file
Directory Chooser
The directory chooser dialog provides a way for users to select a directory. The below code returns something like "file:///media/collier/PROGRAMMING/pybooster/ezwin", if the user chooses a directory. If "Cancel" is clicked, then "Cancel" is returned. Append the "-h" parameter to display hidden files. Because the "--dir" flag is used, the program understands that the "-h" does not mean "help". If the user may select multiple directories, then append the "-m" parameter. The initial path of the directory chooser can be set using the "--path" parameter followed by the path. However, this flag must be the last flag used.
Code:
ezwin --dir
The various EZwin windows can be used together. For instance, the recipe for a chosen color can be saved to a file using the file chooser. An example command is seen below. The "--save" parameter is used to indicate that the file chooser will save a file. The "-n" means the file name rather than the URI will be returned. "--str" will make the file's pathname be returned as a string rather than a list (in square brackets).
Code:
ezwin --color > `ezwin -f --save --str -n`
Further Reading
Dialog - http://www.linux.org/threads/dialog-another-gui-for-scripts.5900/
KDialog - http://www.linux.org/threads/kdialog-kde-gui-for-scripts.5815/
Zenity - http://www.linux.org/threads/zenity-gui-for-shell-scripts.5567/