I write the notes, so to speak.
Just like Barry Manilow writes the songs, except that my songs are coded in Python.
When I come back to a (dot)Py program that I, myself wrote, it seems that I should instantly remember what the heck I was thinking at the time of creation.
But no. Of course not. Upon return, I'm just another customer entering the store for a first time. I have no recollection of having been the creator of the store some many eons ago. Accordingly, I should have the program greet me just as it would any new and unsuspecting customer entering the store (or just as any naïve student of Python entering the classroom).
Here is what such a welcome mat can look like:
First thing to note is that the above screenshot shows a rather primitive User Experience (
UI/UX). No fancy GUI. No cool drop down menu.
Recall however, that this blog is called "Old Man Learns to Code". I'm just starting to learn the ins and outs of Python possibilities. Yes, I'm aware of the existence of the mountain tops, the various
Python GUI builders like PyUiBuilder or TKinter. But my current skill level is that of an amateur mountain climber just starting up the trail that leads into the foothills.
More to the point, I'm using the relatively simple
Colorama module and not diving yet into the complexity of
Rich or the like.
Under the hood are a bunch of function calls to automate the printing on the console of the top set of centered asterisks for the header box, the aligned bottom set of asterisks and the centered welcome message.
Also I'm using a dictionary variable to convert short combinations of three or less characters into the longer form command sequences required by the Colorama module. For example, the string "Buw" tells my dictionary to set Style to BRIGHT, to set the text color (a.k.a. Fore) to BLuE and the background color (a.k.a. Back) to white.
Nothing fancy just yet. But we climb higher and build more complicated structures as we advance. All the while learning how avoid tripping on the little stones. Like remembering to insert sep='' into the print() statement that assembles the Style, Fore and Back codes so as to block the automatic insertion of space characters between the codes, the latter happening if we leave the sep= qualifier out.
Comments
Post a Comment