israel-dryer / PyDataMath-II

A simple Python calculator gui application based loosely on the Texas Instruments DataMath II produced circa 1975 #PySimpleGUI #Tkinter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thanks for the ideas!

PySimpleGUI opened this issue · comments

Wanted to say thank you so much for the support you've shown in your videos.

One of the reasons I like to read as much PySimpleGUI code that other people have written is that I learn something, every time, even from complete beginners.

Your trick of using a dictionary for the parameters was really clever and not a technique I've seen used like this. I normally define a new function that returns an Element when I have repeated parameters and then call that function instead of using the Element itself.

I was surprised and really glad to see you're using the latest and greatest techniques such as the element lookup using window[element_key]. You're clearly paying attention 😊

Your video skills are awesome. I don't have animations or any of those other goodies that you use that really drive home the topics. LOVED the one of showing [ ] around each row of an actual window. In 5 seconds the structure was completely understandable.

Really appreciate what you've done. Thank you.

Thanks! I really like the improvements that you've made in the updated versions.

Believe it or not, the only reason I used the dictionary was because I was trying to figure out a way to write the fewest lines of code that would be reasonably possible and still make it easy to read. I had originally used a function, but then realized I could cut out about 4 or 5 lines by using the dictionaries instead.

I tried a different approach in this video... and used PowerPoint... yes...I did the entire video in PowerPoint. I liked the result so I think I'll probably use it more going forward.

It was VERY well done. My mouth was open the entire duration. I've not seen someone teach me PySimpleGUI quite like this.

At one time I was using lambdas to create these custom Elements, but kinda got yelled at for it because I directly named and called it. But, I may bring it back again.... Lemme know what you think about doing that. I think I used it in the Uno Game originally but may have removed it. It's another thing that I got from reading a user's code.

Oh, and I started using keys with the format:
-NEWKEY-
instead of
_OLDKEY_

The dash, for me, makes them more visible.

One point that I didn't realize people have not been picking up on is the keys can be anything. They can be an object, they can be a FUNCTION, tuple, anything.

Really? now that's interesting.... so I can call the events directly as functions... now that's cool.

image

I added a test for iscallable to a script recently so that it would just automatically call. However, because keys need to be unique, it's better to use a lambda. That way you can pass to the callback other stuff.

Speaking of other stuff... there's now a metadata field in all of the Element's constructors. You're free to store whatever you want in there and can access it directly using Element.metadata. It's too new to be documented. It's not been cross-ported so it's only on tkinter version.

I hesitate to provide it however as I don't want to see it used in a weird way that attempts to mold PySimpleGUI into the older architectures. I think a friend of mine may be using it in a designer he's been working on.

I think if you make the key a callable, then you may need that metadata field to pass through something important.

You can make keys be objects too. Or a tuple with a lambda and ? Or......

It's been very inspirational to see your video. HUGE boost from that last one! It's got me excited again.

Another weird change I made that isn't well advertised as I've not been using it yet, is that you can "call a window" and it will perform the read. This means you can essentially drop these literal characters .read and your code will continue to work.

I'm torn about using it, but damn, I love the minimal code you're left with.

    event, values = window()

Oh, and elements are callable too. You could potentially drop any .Update or .update characters from your code.

window['-display-']("The first field is always value")

Second to strings as Keys, I use tuples. This is very helpful when you've got a grid of anything. Say, a grid of buttons, or a grid of input text boxes that look like a spreadsheet. It makes sense that window[(4,5)] will return the input element located on the 4th row and 5th column of a "Table" of input elements (see the Simulated Table demo program).

I'm pretty sure I use tuples in the chess game too.

I'll have to remember the index method.. that could come in handy! Calling the window directly is interesting... it would feel like window = sg.Window() is creating a function rather than an object. I think I could get used to that, but it would definitely feel weird at first.

Yea, it's sorta like that... except it is still an object.
It's a uniquely Python thing as far as I know.

Elements are callable and so are windows. When you call an element, it calls the Update method. When you call a window it calls the Read method.

I would like to get your permission to post some screenshots of your PySimpleGUI apps on the GitHub. I have an Issue that has screenshots of other people's creations.

I need to break out another one that just has the best of all of them... mine and other people's too. A gallery of sorts. The problem with using an Issue like I did is that it hides entries when you get too many. So most of the good screenshots are hidden.

absolutely. go for it if you see anything worthy of posting. :-)

By the way, this is the BEST forum I've ever been a part of:
https://forum.pythonistacafe.com/

It's a paid forum however, which is perhaps why it's filled with nice people. If you're really into Python, it's a "Safe Space" to ask any kind of question, make any kind of statement and you'll be treated with respect.