Pysimplegui: Question: how to ensure fixed window size in pixels that matches display size for an embedded application in a dedicated hardware device

Created on 20 Sep 2019  路  2Comments  路  Source: PySimpleGUI/PySimpleGUI

Type of Issues (Enhancement, Error, Bug, Question)

Question

Operating System

Mac OS X 10.14.5 Mojave
Linux Raspbian Jesse

Python version

Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin

PySimpleGUI Port and Version

Version: 4.4.1 tkinter

Your Experience Levels In Months or Years

___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

You have completed these steps:

  • [ x] Read instructions on how to file an Issue
  • [ x] Searched through main docs http://www.PySimpleGUI.org for your problem
  • [ x] Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • [ x] Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • [ x] Note that there are also Demo Programs under each port on GitHub
  • [ x] Run your program outside of your debugger (from a command line)
  • [ x] Searched through Issues (open and closed) to see if already reported

Code or partial code causing the problem

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?

documentation

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:

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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eyeonus picture eyeonus  路  6Comments

MikeTheWatchGuy picture MikeTheWatchGuy  路  3Comments

flowerbug picture flowerbug  路  4Comments

lucasea777 picture lucasea777  路  3Comments

MikeTheWatchGuy picture MikeTheWatchGuy  路  6Comments