Project 1- Building a Master TCL/TK Macro
Objective:
This project objective is to combine all previously prepared scripts into one master window that will allow for easy access to them. Master GUI should be divided into categories that will segregate scripts acorrding to their usage. Every script should have dedicated run button. User should be able to run multiple scripts, and they must work independently.
Problem Statement:
For inexperienced user running scripts directly from .tcl file can be intimidating. In order to facilitate using scripts a master gui window that will store and allow for running scripts is a must. While new scripts are being developed a smart solution for auto updating Gui is also needed. Scripts can be divided into groups according to their usage (ex. scripts that work on geometric entities, mesh entities, or scripts used for final check) for easy and intuitive access.
Tcl command explanation:
For this script I wanted to prepare master gui that will initiate with sourcing all scripts that are present in folder and automatically create buttons, and arrange them to tabs. This will allow me for easy adding new scripts, they simply will have to be inside master script folder before executing master.tcl.
In this script I use notebook like tab display, found on wiki.tcl-lang.org, that is written in pure Tcl so no need for importing pacages what is nice and meets all my demands. What I did to this code was adding 3 tabs named GEOM, MESH, FINAL and creating buttons in right place. For this purpouse I had to establish script naming convention to have controll over in which tab button will appear. Naming convention is as follows: first capital letter determines which tab does this script belong to (ex G_mid_line.tcl - belongs to tab GEOM).
Following modifications needed to be made to all scripts in order to allow for running multiple scripts at time. Every script was wraped into procedure to seperate them betweend each other and from global namespace. Proc name is simply script name without first capital letter, has one input based on script name that is passed when creating window to have unique name.
_master.tcl script starts with reading script path, based on that reads all files in this folder and stores its tails to file_list. This list is than converted to script_list ommiting .tcl ending. Window is set to be resizable and topmost all the time. Foreach loop for creating buttons sources script_list, initally checking first capital letter via switch function and passes script name to buttons. Each button is linked to RunScript proc that has input of script name, inside this proc script name is concatenated with path and run via source command.
Conclusion:
When it comes to creating scripts having them run bug free and execute what was meant to do is not whole succes, it is important to provide user with easy way of seaching and executing. Only when scripts are given to end users in neat and easy accessible way we can assume they will be used on daily basis. Solutions I used during creating this script also facilitate maintenance and allow for fututre development of this master gui.
All the scripts have been checked for null cases, and interference between each other. Colour coding is not nessesary for me, displaying scripts in tabs makes them more clearly visible in my case. Future development of this gui will include popup icons with script description, or some dedicated space inside master window to present description.
Summing up, I gathered all usefull scripts in one master window, that is made to be as maintenance free as possible. It will be introduced to my team as result of my course. Hopefully my colagues will get used to using those tools and propose new ideas where improvement can be done. With the knowledge I aquired during this course I'm not afraid to undertake any challenge that will occur in scripting HyperMesh :)
created by Adam