1

I would like to update the property no_titlebar of a PySimpleGUI Window.

What I want is that, when we click a button, the window which was initially having titlebar should be having no titlebar.

Is there any way to Implement this ?

from PySimpleGUI import *
lt=[[Button("No Layout")]]
wn=Window("Test",lt,no_titlebar=False)
while True:
    e,v=wn.read()
    if e=="No Layout":
        wn.Update(no_titlebar=True)
    else:
        break

I tried this but was getting an AttributeError

AttributeError: 'Window' object has no attribute 'Update'
1
  • Yes, you got the answer 'Window' object has no attribute 'Update'. Commented Oct 27, 2021 at 9:40

2 Answers 2

1

There's no method Update for sg.Window, and no method to update no_titlebar.

Following code just for your reference, I know nothing about Linux, so you may need to find the answer by youself about what value for window.TKroot.wm_attributes("-type", value) to restore toolbar.

import PySimpleGUI as sg

def titlebar(state):
    try:
        if sg.running_linux():
            if state:
                window.TKroot.wm_attributes("-type", 'normal')  # Don't know what the option `normal` should be ...
            else:
                window.TKroot.wm_attributes("-type", 'dock')
        else:
            if state:
                window.TKroot.wm_overrideredirect(False)
            else:
                window.TKroot.wm_overrideredirect(True)
    except Exception as e:
        print(f'** Problem setting no titlebar {e} **')

layout = [
    [sg.Button("Title bar On/Off"), sg.Button('Exit')],
]

window = sg.Window("Test", layout)
state = True
while True:

    event, values = window.read()

    if event in (sg.WINDOW_CLOSED, 'Exit'):
        break
    elif event == "Title bar On/Off":
        state = not state
        titlebar(state)

window.close()
Sign up to request clarification or add additional context in comments.

Comments

0

Check the spelling. Python is case-sensitive. 'Window' object has an attribute 'update' and 'Window' object has no attribute 'Update'

1 Comment

It's not the spelling issue, the instance of the class Window don't have an attribute or method named update or Update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.