Question
Mac OS X 10.14.5 Mojave
Linux Raspbian Jesse
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Version: 4.4.1 tkinter
___1 month______ Python programming experience
___47 yrs______ Programming experience overall
_________ Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)? not for Python
I am a newbie to PySimpleGUI (and Python), but have decades of experience with PHP, JavaScript, Java, C, Pascal, PL/1, FORTRAN, BASIC and LISP
In the documentation it is noted that some elements use sizes in pixels while most are in what appears to be something like rows and columns (maybe based on Font Height and M-size?).
i am developing the GUI to control an embedded system for a Raspberry Pi. This system will have a built-in display that is 1024 x 720 pixels.
I would like to ensure that the window is the full size of the display since this is supposed to be a dedicated application and device.
It appears that Window is one of those elements that is not defined in pixels. I could not find anywhere in the documentation that defines how to specify a window size that is ensured to not be larger than the display it is shown on, and hopefully not smaller either.
Can that be addressed by adding an example to the Cookbook?
If you have a window that you want to take the entire screen, then I would suggest maximizing the window. Additionally, setting no_titlebar will cause only the contents of the window to be displayed. The user will not have the ability to minimize or close the window (unless you provide a button) as the titlebar controls are removed.
It's tricky getting the size of the screen. In order to do that, you much first create a window. You could create a window that's "hidden" (set alpha=0 when creating it), then get the size of the screen, then resize the window.
The easiest approach will be to not worry about the exact size of the window and instead maximize your window to take the entire display regardless of the size.
It appears that the documentation on the Window's available methods only includes the Size property for reading. It doesn't show that you can also change the window's size using the same window.Size((x,y)) call. I'll get that added to the docs.
I just checked in changes that will help your specific use case.
There is a new Window class method that will return the screen dimensions, even if you don't have a window open yet. You call:
import PySimpleGUI as sg
print(sg.Window.get_screen_size())
w, h = sg.Window.get_screen_size()
The old function get_screen_dimensions will continue to work. It in fact works better now as it will work correctly on windows that have been closed/destroyed.
Most helpful comment
I just checked in changes that will help your specific use case.
There is a new Window class method that will return the screen dimensions, even if you don't have a window open yet. You call:
The old function get_screen_dimensions will continue to work. It in fact works better now as it will work correctly on windows that have been closed/destroyed.