Week 5: Tabular Formatting

Apr 07, 2020

Hello again!

I am slowly getting closer and closer to my final goal, and it is exciting to start to see the light at the end of the tunnel. I talked with my onsite advisor about my next steps, and we agreed that my goal for this week should be getting my GUI to look more like my plan: a table. Before this week, all of the content and function was there, but it looked kind of sloppy. When I started developing the user interface a few weeks ago, I tried to use the table function that they had, but after I couldn’t get it to work, I just inserted text boxes. The problem with tables is that there is very little information about the sg.Table function in PySimpleGUI’s user manual. With more knowledge of the library and Python in general, I was able to make my way around this problem.



I started with an example in the manual. It was just a table with a bunch of random strings in them, and I eventually figured out how to get data in there. Click to view my original plan, GUI script, screenshot, and XML file. Try it out if you’d like!

Basically, the sg.Table function takes an index as input. An index is a list of lists, for example: [[task1, description1, status1, start date/time1, logging1], [task2, description2, status2, start date/time2, logging2], [task3, description3, status3, start date/time3, logging3]].

One of the hardest parts of switching my program to a tabular format was updating values. In the beginning, there are a lot of blank spaces in these indexes, since there is nothing to list for “Start Date/Time” and “Logging.” But as the different tasks run, values are supposed to pop up in these spaces. After playing around for hours, I figured out that you can give the whole table a key. You can reference that key later, but because the key takes the entire table into account, you have to feed it a complete index with the new updated values. After figuring that out, it was tedious but relatively simple to get done.

Another hard part was getting the program to sense where the User Pauses are and how many there are.  I struggled with this last week, too, but this week was different. I was still running “for” loops through the IDs of each task, but this time, I also had to take into account the User Pauses. These are not in the XML file as tasks, but they are in the layout indexes, just like the other tasks. As you may imagine, this messed up my loops and ID numbers from before.

One cool thing that I got working in this new format was clicking on the links. I can’t use buttons inside the actual table, but I still have to be able to click on the directory links. To do this, the table key that I mentioned before can also function as an event where if you click on a row, it will return a 0, 1, 2, …, (n). With this returned number, I set up some “if” statements and “for” loops that compare the XML tasks and GUI tasks (different because GUI tasks include a variable number of User Pauses). Once it finds the right task in the XML file, the system opens up a folders window in the specified directory.

Here are a couple of other smaller things that I accomplished:

–    Made a new task that has the sole duty of checking if the produced files are in the zip file called Check1 and Check2. This also allowed me to test out the program’s ability to take on a variable number of tasks.

–    Made a new subcategory that includes information that applies to all tasks, such as directory path and expected files. This saves space in both the XML file and the program, and also makes this data easier to access.

–    Went through my whole program to see if there was anything that I could cut or consolidate with some inclusive functions. For example, if I have six lines of code that repeat five times for each task, I can make a function that is defined by those six lines. Then, I can reference this function with just one line, in this situation cutting a total of 18 lines.



This week was just as enjoyable as the last – as I said in my previous blog, it feels great when something finally works after hours of troubleshooting. This week’s experience was especially nice because I figured out the sg.Table function, which I tried and gave up on weeks before.

While Unanet’s office environment was great, working from home has been quite a pleasure. First off, I can work whenever and however long I want to (I tend to get a lot of work done late at night). Secondly, when I have creative blocks, I can eat or play the piano for a few minutes. I have also found that pacing or lying on my bed can bring some new ideas to mind.

Next week, I will try to polish the GUI even more. Once I do that, I can hopefully move onto the customer’s test environment to see how my work does. Stay tuned to find out!


4 Replies to “Week 5: Tabular Formatting”

  1. Charles T. says:

    Wow Tommy! Looking through your code, great job on the progress. Look forward to hearing about your progress with GUI next week.

  2. Tad B. says:

    Glad that you are making good progress. It sounds like you have adapted well to working from home! Stay safe, and keep up the good work!

  3. raulr says:

    All this sounds great! It seems like you found your “flow” and that is very important. I always made a connection between programming and music composition… for me they are both artistic and methodical, and both can sometimes lead to writer’s block of some kind. I like how you have found ways to get distracted enough to overcome it and still stay on task.

    If you go to the piano to get a break from programming, does it mean I should I get into programming to get a break from composition? Oh, the struggle.

    Anyway, keep up the good work!

    1. Thomas E. says:

      I totally agree – music and coding have a lot of similarities. I have recently been playing Claude Debussy’s “Claire de Lune,” and the learning process for that was just the right complement to my software development project.

Leave a Reply