You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
window['key'] can replace window.FindElement('key')
This is important enough to warrant an Issue being opened to get your attention
A change was made to all 4 ports to enable this capability. I saw the suggestion less than an hour ago. This is SO cool and makes writing the code so much cleaner!
100% of the credit goes to @nngogol for this. He provided the idea and some sample code. THIS is how PySimpleGUI should be doing it!! It's making use of a specific Python feature in a way that is EASY for programmers to use.
NOTE - you can continue to call window.FindElement and Window.Element. I will be keeping those around. However the readme/User Reference, Cookbook will both change to using this new method instead of the FindElement call. Also, like so many other SDK changes, the Demo Programs will be updated over time and the new ones will use the new technique.
I'm ELATED! It's cleaner, more Pythonic, and just plain rocks. You'll still get the same error message, by the way, should you provide a bad key.
In case the heading above doesn't explain it, this will.
I'll also tack onto this Issue a potentially new way of accessing an Element's Update method.
This change has not yet gone into the other ports of PySimpleGUI (Qt, etc), whereas the FindElement one has been ported.
A new way of calling Update is to make a call to whatever is returned from a FindElement call (or brackets now).
In the above example, the code was compacted using [ ] to this:
window['_TEXT_'].Update(values['_INPUT_'])
This new, addition compaction, involves removing these characters in the above statement .Update, making the new statement:
window['_TEXT_'](values['_INPUT_'])
Yes, that's valid. And yes, it works!
How to explain this in comments and in the User's Manual is going to be crazy. Totally understand how to explain the [ ] change, but this one of skipping the Update word is a different thing.
window['key']
can replacewindow.FindElement('key')
This is important enough to warrant an Issue being opened to get your attention
A change was made to all 4 ports to enable this capability. I saw the suggestion less than an hour ago. This is SO cool and makes writing the code so much cleaner!
100% of the credit goes to @nngogol for this. He provided the idea and some sample code. THIS is how PySimpleGUI should be doing it!! It's making use of a specific Python feature in a way that is EASY for programmers to use.
NOTE - you can continue to call
window.FindElement
andWindow.Element
. I will be keeping those around. However the readme/User Reference, Cookbook will both change to using this new method instead of theFindElement
call. Also, like so many other SDK changes, the Demo Programs will be updated over time and the new ones will use the new technique.I'm ELATED! It's cleaner, more Pythonic, and just plain rocks. You'll still get the same error message, by the way, should you provide a bad key.
In case the heading above doesn't explain it, this will.
Previously Updating An Element:
NOW Updating An Element:
And here's an entire program using it:
The text was updated successfully, but these errors were encountered: