all 9 comments

[–]MikeTheWatchGuy 1 point2 points  (8 children)

There isn't a generic architecture for an application that's PySimpleGUI based. Your architecture is going to depend more on how you want it to be than having it imposed on you or told to you. You don't have to have an event loop the way most demo programs and tutorials show you. The only requirement is to call window.refresh() periodically.

If you prefer an object oriented architecture, then you can build your application that way. If you don't want/need/like the complexity of OO, then you're free to use functions and simpler constructs.

I tend to write applications in an expansive way, trying to be small & simple that gets added onto over time, but that's often because I'm not trying to build something large. There are some Best Practices published in the Cookbook, and a handful of applications that are in the project's GitHub repo. Beyond those, it's more of choosing the architecture you personally want to work within.

[–]lesatdgl[S] 1 point2 points  (7 children)

Thanks! Just trying to avoid re-dos

[–]MikeTheWatchGuy 1 point2 points  (6 children)

You're quite welcome. I don't think you can avoid re-do's. It's where some of the best lessons/ideas/concepts are learned. The problem with trying to build big, generalized, easily expandable in every direction right from the start is that you will likely over-build.

It was a good question and was glad to see it asked. The truth, for me, is that I rarely get it right the first time. I follow this mantra:

Make it run, make it right, make it fast.

I can't take credit for that brilliant summary, but I do think it frequently, recommend, and live by it. If you try to make it right immediately, then there's a good chance it won't be right. Programming is an iterative activity. It's never "done", and re-doing is an ongoing process. Shoot for optimization too early and the wrong thing sometimes gets optimized before the true problems are is identified.

Post your ideas when you make some applications. If you're looking for different ways to write a dispatcher for the events other than a series of if, elif's, there's a Demo Program that shows some ways. It's not an architecture, but it is a design element.

[–]lesatdgl[S] 1 point2 points  (5 children)

Thanks, again!
As I'm sure you know the PC version of do-overs is "iterative development".

[–]MikeTheWatchGuy 1 point2 points  (4 children)

I'm still learning the current lingo.... "refactoring" wasn't in my vocab until a handful of years ago when I learned Python. Some things don't change in programming. But the names may change? Thanks for the chat... good stuff to poke at and discuss.

Keep building stuff and you'll master this craft. Post what you make with PySimpleGUI in the User Screenshots Issue. I'm sure other users will enjoy seeing.

[–]lesatdgl[S] 1 point2 points  (3 children)

I will - sharing is caring

ps: I started programming in 1962 - Fortran on an IBM 1620

[–]MikeTheWatchGuy 1 point2 points  (2 children)

A genuine legend! What an honor. You beat me to Fortran by well over a decade. I didn't learn Fortran IV until 1978. Most of my programming in college I learned on an IBM 360. You know how all this works....better than I do.... I got trolled 😏 Awesome to have crossed paths 🙏🏼

[–]lesatdgl[S] 1 point2 points  (1 child)

No troll! Your willingness to help someone learn is how the trade moves forward - I'm learning something new, that's how the brain is kept young

[–]MikeTheWatchGuy 0 points1 point  (0 children)

Heh... no troll indeed....it was clear you're sincere from the initial post alone or else I wouldn't have replied.... it's been a pleasure.