With version 4.2, I turned my attention to facilitating rework in PAGE. That is, how do you use PAGE to tweak the GUI without loosing the supporting code that you have written? At the same time I want to allow one to view the changes with the run command button in the Python console.
Here is the situation. You built a GUI and generated the Python file, which created skeleton functions in that file. You then fleshed out the skeleton functions to support the GUI and then decided to modify the GUI. If then you again generate the Python code for the GUI, you will have replaced the filled-out functions with new skeleton functions loosing the code you wrote. This is the rework problem: How to save your hard fought code when reworking the GUI.
What needs to be done is to separate as completely as possible the automatically generated GUI code from the added support code. I have made some changes that move in that direction in version 4.2.
My answer is to separate the generation of the GUI code from the supporting code by placing the support portion of the automatically generated code into a separately generated module to be imported by the GUI module. That is, now PAGE generates two modules, one for the GUI and one for the supporting code complete with the necessary linkage.
PAGE implements this schema as follows. Heretofore, a GUI built with PAGE was associated with two files, “<name>.tcl” which is the file suitable for input to PAGE, and “<name>.py” which is output of PAGE containing the Python code for creating the GUI object and skeleton functions and Tkinter variables utilized by the GUI. In the new scheme, the skeleton functions and Tkinter variables are generated in the new file “<name>_support.py” rather than in “<name>.py”. A new item, Generate Import Module, has been added to the Gen_Python submenu of the main menu which generates “<name>_support.py”. The new support file is presumably only generated once and is where the bulk of the code realizing the application is written. “<name>” is the application name selected by the user when the system saves the ”.tcl” or extracted from the file name which may be supplied when invoking PAGE.
Thus, one may alter the “<name>.py” using PAGE without changing the “<name>_support.py”. Of course, if the user changes the GUI and refer to new callback functions or Tkinter variables, then those will have to be manually added to the support module. The style of the skeleton functions and TK variable additions is pretty simple so that they are easy to add manually.
Let me repeat: You should only generate the support module once; otherwise any code which you added will be lost. Well, just in case you do that inadvertently, PAGE will save some previous versions as backups. If you add new features specifying new callback functions or new Tk variables you will have to add them manually to the supporting module.
See the WCPE directory in the examples directory. This is a program that displays the program of WCPE which is one of my favorite classical music stations. In this example all of the functional code is located in WCPE_support.py and the GUI is defined in WCPE.py which is the main module. I found it very tricky to deal with time zones and did not want to loose any of that code and have to redo it or to deal with diff’s ; at the same time, I was constantly tweaking the GUI. I generated the import module once and proceeded fill out the init function and the callback functions in WCPE_support.py while tweaking the GUI, i.e., changing its location, color, the size of the display fields, etc..
Also, in the examples directory, you should compare the progress_bar and the rework_progress_bar. The directory rework_progress_bar contains the changes that I made to the files in progress_bar to conform to the new rework scheme. It may be instructive in that it exemplifies an application comprised of two top level windows where one of the windows accesses Tkinter variables in the second window.
With chagrin, I apologize to PAGE user for not having thought of this solution to rework long ago. Even though I have tested the idea with several examples, some of which are included in the section on examples, I worry that I have overlooked something big. So if you find any problems or oversights, please let me know.