4.15.2 Released 15-Jan-2020
This is critical to know. Knowing where your PySimpleGUI.py file is located is just as important. You can get these by adding this to the top of your file and running it:
import PySimpleGUI as sg
print(sg)
print(sg.version)
____2y_____ Python programming experience
_________ Programming experience overall
____yes_____ Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?
I used the code of the program https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Save_Window_As_Image.py to save my images as PNG Files. This works fine.
The problem occurs after I increased the screen resolution from 1360x768 to 1920x1080 to save larger images. Only part of the image was saved. The same problem occurs with the demo program:
original screen resolution 1360x768:
Going to lower resolution than original seems to work
My question is: what part of python do I have to reinstall in order to make the script working again?
Otherwise I am very satisfied with PySimpleGUI, see https://meteorspectroscopy.org/2020/03/27/meteor-spectra-analysis-new-version/ for a description of my script based on it
Demo_Save_Window_As_Image.py see above
Demo programs provide 2 functions. They provide design patterns / examples of how to use specific PySimpleGUI features or functions. The other thing they do is demonstrate ways of integrating your application with other packages or libraries. They're not meant to be full-blown applications but as implied, demos. I'm not a PIL expert so I don't know how to advise you on how to best solve your problem using the PIL package.
The Meteor Spectra Analysis program is quite impressive!
Sometime I also have problems on resolution of display. It is not caused by PySimpleGUI, but tkinter.
Function TkWinDisplayChanged in tkinter uses the windows API call GetDeviceCaps to get the screen width and height with the parameters HORZRES and VERTRES.
In GetDeviceCaps, there's note:
GetDeviceCaps reports info that the display driver provides. If the display driver declines to report any info, GetDeviceCaps calculates the info based on fixed calculations. If the display driver reports invalid info, GetDeviceCaps returns the invalid info. Also, if the display driver declines to report info, GetDeviceCaps might calculate incorrect info because it assumes either fixed DPI (96 DPI) or a fixed size (depending on the info that the display driver did and didn’t provide). Unfortunately, a display driver that is implemented to the Windows Display Driver Model (WDDM) (introduced in Windows Vista) causes GDI to not get the info, so GetDeviceCaps must always calculate the info.
It means the result is not trusted, so most of time, I add this into my script before where tkinter used, and most of time it work fine. Not to switch reslution when python or tkinter running, some values will be stored and kept unchanged.
import ctypes
ctypes.windll.user32.SetProcessDPIAware() # Set unit of GUI to pixels
Perhaps you can try it.
@Jason,
thanks a lot for your advice. I added the two lines to my code and it works for all resolutions.
That is what I like about PySimpleGUI: I always get solutions to my problems. Also very quick response. Great!
Martin
This one is all @jason990420 !!! WOW, Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Most helpful comment
@Jason,
thanks a lot for your advice. I added the two lines to my code and it works for all resolutions.
That is what I like about PySimpleGUI: I always get solutions to my problems. Also very quick response. Great!
Martin