EZWin - Yet Another Script GUI

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
Code:
ezwin -i "This is a message."
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.
Code:
ezwin -i $(whoami; echo '\n'; date)

ezwin-info.png


Message
To make a message dialog, type
Code:
ezwin -m "This is a message."

ezwin-msg.png


Warning
To make a warning dialog, type
Code:
ezwin -w "This is a warning."

ezwin-warning.png


Error
To make an error dialog, type
Code:
ezwin --err "This is an error."

ezwin-error.png


Update
To make an update dialog, type
Code:
ezwin -u "This is an update message/warning."

ezwin-update.png


Security
To make a security dialog, type
Code:
ezwin -s "This is a security message/warning."

ezwin-security.png


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?"

ezwin-question.png


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?"

ezwin-ync.png


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?"

ezwin-ynq.png


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?"

ezwin-yncancel.png


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."

ezwin-typetext.png


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."

ezwin-typecancel.png


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."

ezwin-password.png


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."

ezwin-pswdcancel.png


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

ezwin-color.png


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

ezwin-file.png


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

ezwin-dir.png


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/
 

Attachments

  • slide.jpg
    slide.jpg
    39.1 KB · Views: 14,806



Members online


Latest posts

Top