Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How do I redraw the entire window layout in PySimpleGUI #6721

Open
10 tasks
xmlztw opened this issue Mar 22, 2024 · 4 comments
Open
10 tasks

[Question] How do I redraw the entire window layout in PySimpleGUI #6721

xmlztw opened this issue Mar 22, 2024 · 4 comments
Labels
Port - TK PySimpleGUI question Further information is requested

Comments

@xmlztw
Copy link

xmlztw commented Mar 22, 2024

Type of Issue : Question


Operating System

PySimpleGUI Port : 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.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]

PySimpleGUI Version : 4.60.5

GUI Version : 8.6.1

Troubleshooting

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

  • Searched main docs for your problem PySimpleGUI Documenation
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demo Programs
  • None of your GUI code was generated by an AI algorithm like GPT
  • 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.com
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried running the Development Build. Your problem may have already been fixed but not released. Check Home Window for release notes and upgrading capability
  • For licensing questions please email license@PySimpleGUI.com

Detailed Description

How do I redraw the entire window layout in PySimpleGUI? I tried calling self.window.layout(layout), but it didn't work.

@pysimpleissue pysimpleissue bot closed this as completed Mar 22, 2024
@xmlztw xmlztw changed the title [Question] NOTE - you can also call sg.main() or sg.main_open_github_issue() to post an issue [Question] How do I redraw the entire window layout in PySimpleGUI Mar 22, 2024
@xmlztw
Copy link
Author

xmlztw commented Mar 22, 2024

Type of Issue : Question

Operating System

PySimpleGUI Port : 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.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)]

PySimpleGUI Version : 4.60.5

GUI Version : 8.6.1

Detailed Description

How do I redraw the entire window layout in PySimpleGUI? I tried calling self.window.layout(layout), but it didn't work.

@jason990420
Copy link
Collaborator

More detailed information: Missing Troubleshooting Section

Better not to remove any section of the issue form, like this

Troubleshooting

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

  • Searched main docs for your problem PySimpleGUI Documenation
  • Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demo Programs
  • None of your GUI code was generated by an AI algorithm like GPT
  • 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.com
  • Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
  • Tried running the Development Build. Your problem may have already been fixed but not released. Check Home Window for release notes and upgrading capability
  • For licensing questions please email license@PySimpleGUI.com

@pysimpleissue pysimpleissue bot removed Fill issue form or you will be REJECTED You MUST use the supplied template to submit a request. PySimpleGUI Issues Bot Has Detected an Error labels Mar 22, 2024
@pysimpleissue pysimpleissue bot reopened this Mar 22, 2024
Repository owner deleted a comment from pysimpleissue bot Mar 22, 2024
@jason990420
Copy link
Collaborator

jason990420 commented Mar 22, 2024

layout(rows)

Second of two preferred ways of telling a Window what its layout is. The other way is to pass the layout as
a parameter to Window object. The parameter method is the currently preferred method. This call to Layout
has been removed from examples contained in documents and in the Demo Programs. Trying to remove this call
from history and replace with sending as a parameter to Window.

To update your GUI immediately, call window.refresh(), or the GUI will be updated only until you call window.raad().

To renew your window, you may do it like following example, new elements in the layout will all be reinitialized, not reuse the layout.

import PySimpleGUI as sg

def new_window(width=45):
    layout = [[sg.Input(size=width, key='-IN-'), sg.Button("OK")]]
    return sg.Window("Title", layout, finalize=True)

window = new_window()

while True:

    event, values = window.read()

    if event == sg.WIN_CLOSED:
        break

    elif event == "OK":
        try:
            n = int(values['-IN-'])
        except:
            n = -1
        if 0 < n < 80:
            win = new_window(n)
            window.close()
            window = win

window.close()

@jason990420 jason990420 added question Further information is requested Port - TK PySimpleGUI labels Mar 22, 2024
Repository owner deleted a comment from pysimpleissue bot Mar 23, 2024
@PySimpleGUI
Copy link
Owner

If you want to retain the values already entered into the window, then you can use the new setting parameter was added to elements in the PySimpleGUI 5 release.

You will need to upgrade your environment, which I recommend regardless as you're running a very old version of Python (3.4) and an extremely old version of tkinter (8.6.1). You should be getting a warning message about your tkinter version being too old.

The parameter is shown in the documentation, primarily here:
https://docs.pysimplegui.com/en/latest/documentation/module/user_settings/#settings-defined-in-layouts

I added a Demo Program that shows how to use this parameter as well and included an example of "restarting" / redrawing a window should you need a feature like this for you application.

https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_User_Settings_Element_setting_Parameter.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Port - TK PySimpleGUI question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants