I started working through the 100 Days of Code course of Udemy last February, and I’m in the home stretch. I’m on the final lessons, which are really just prompts for projects. No hand holding, just a brief description of the goal. I recently finished a tkinter GUI program, the goal of which was to enable adding text watermarks.

I took a few liberties–mainly, I made it possible to layer a png on top of the background. It was a really fun project and quickly grew more complicated than I expected it to. I got some hands on experience with the Single Responsibility Principle, as I started off doing everything in my Layout class.

Eventually, I moved all the stuff that actually involved manipulating the Image objects to an ImageManager class. I feel like I could have gotten even more granular. That’s one thing I would love to get some feedback on. How would a more experienced programmer have architected this program?

Anyway, I guess this preamble is long enough. I’m going to leave a link to the repository here. I would have so much appreciation for anyone who took the time to look at the code, or even clone the repo and see if my instructions for getting it to run on your machine work.

Watermark GUI Repo

  • Hammerheart@programming.devOP
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    7 days ago

    I just want you to know you weren’t screaming into the void. Look at my new main.py:

    
    from pathlib import PurePath
    
    
    from Layout import Layout
    
    
    DEFAULT_FOLDER = PurePath("/home", "mike", "bg")
    WATERMARK_DIR = Path(Path(os.getcwd()).parent, "assets", "img")
    
    
    def main() -> Layout:
        return Layout()
    
    if __name__ == "__main__":
        main()
    

    (I know I still need to change those folder defaults, but I am still riding the high of getting all that layout stuff into Layout.py and it working. I spent a couple hours today struggling, wondering why I was just getting a blank screen, when i realized i forgot to call .grid() on the frame that held all the widgets! So it was just rendering a blank window. )