Yogesh Aggarwal
Yogesh Aggarwal

Reputation: 1127

How do remove the "Ok" button in popup (PySimpleGUI)

Typical popup:

sg.Popup("This is a simple popup")

This will show an "Ok" button with my text which I don't want. How can I remove this button?

Upvotes: 2

Views: 2569

Answers (2)

Mike from PSG
Mike from PSG

Reputation: 5764

You should be calling popup_no_buttons rather than changing the button_type parameter. The documentation states that it's not meant to be used by users.

import PySimpleGUI as sg

sg.popup_no_buttons('This is a popup without buttons')

If you do use it, it's recommended you use the "enum" values for that parameter so that if the numbering changes your code will continue to function. That value is sg.POPUP_BUTTONS_NO_BUTTONS

Upvotes: 2

Yogesh Aggarwal
Yogesh Aggarwal

Reputation: 1127

Just provide the button_type argument like this:

sg.Popup("This is a simple popup", button_type=5)

In PySimpleGUI there are 5 types of button configurations:

Yes, No: 1
Cancel: 2
Error: 3
Ok, cancel: 4
No button: 5

Upvotes: 2

Related Questions