[Question] sg.Image , How to adapt to different screen sizes #5541

@monkeycc

Description

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

Question

Operating System

WIN11

PySimpleGUI Port (tkinter, Qt, Wx, Web)

tkinter

Versions

Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()

Python version: 3.7.13 (default, Mar 28 2022, 08:03:21) [MSC v.1916 64 bit (AMD64)]
port: tkinter
tkinter version: 8.6.9
PySimpleGUI version: 4.59.0
PySimpleGUI filename: D:\anaconda3\envs\PySimpleGUI \lib\site-packages\PySimpleGUI\PySimpleGUI.py

Your Experience In Months or Years (optional)

Years Python programming experience
Years Programming experience overall
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
tkinter
Anything else you think would be helpful?

Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
  • If not tkinter - looked for Demo Programs for specific port
  • For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
  • Detailed Description

    sg.Window.get_screen_size()
    1920*1080
    2560*1440
    3840 *2160
    

    sg.Image , How to adapt window size

    How to adapt to different screen sizes
    sg.Image sg.Frame sg.TabGroup sg.Window
    size=(get_screen_size_ok[0],get_screen_size_ok[1])

    Code To Duplicate

    import PySimpleGUI as sg
    get_screen_size_ok = sg.Window.get_screen_size()
    tab4_layout = [
                                    [sg.Frame('hello', [
                                    [sg.Push(),sg.Image(filename="F:/1.png"),sg.Push()],
                                    [sg.VPush()],
                                    [sg.VPush()],
                                    [sg.Push(),sg.Button('go'), sg.Button('stop',disabled=True),sg.Push()]
                                        ], key="_Frame01_",border_width = 1,title_color="#515a6e"),
                                    sg.Frame('hello2', [
                                    [sg.Push(),sg.Image(filename="F:/1.png"),sg.Push()],
                                    [sg.VPush()],
                                    [sg.VPush()],
                                    [sg.Push(),sg.Button('go'), sg.Button('stop',disabled=True),sg.Push()]
                                        ], key="_Frame02_",border_width = 1,title_color="#515a6e"),
                                    [sg.VPush()],]
    tab5_layout = [[sg.Text('This is inside tab 5')],
                   [sg.Input(key='-in4-')]]
    layout = [
        [sg.TabGroup([[sg.Tab('Tab 4', tab4_layout),
                             sg.Tab('Tab 5', tab5_layout)]],size=(get_screen_size_ok[0],get_screen_size_ok[1]) )],
    window = sg.Window('Window Title', layout,resizable=True,finalize=True,size=(get_screen_size_ok[0],get_screen_size_ok[1]))
    window.maximize()
    while True:
        event, values = window.read()
        if event == sg.WINDOW_CLOSED or event == 'Quit':
            break
    window.close()

    Screenshot, Sketch, or Drawing