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] Remove "Ok" button from popup #2608

Closed
yogesh-aggarwal opened this issue Feb 14, 2020 · 3 comments
Closed

[Question] Remove "Ok" button from popup #2608

yogesh-aggarwal opened this issue Feb 14, 2020 · 3 comments

Comments

@yogesh-aggarwal
Copy link

Question

I want to remove the "Ok" button packed by default with my simple popup (using popup with no title bar).

Operating System

Arch Linux

Python version

3.8.1

PySimpleGUI Port and Version

4.15.2

Your Experience Levels In Months or Years

1 month
5 Python programming experience
8 years of Programming experience overall
yes (tk) Have used another Python GUI Framework (tkiner, Qt, etc) previously (yes/no is fine)?

@yogesh-aggarwal
Copy link
Author

Found the solution by taking a look at source code (psg).
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

@PySimpleGUI
Copy link
Owner

I crack up when people ask for changes to popup.

Don't be afraid of making your own popup / window. You can create, display, read and close a window in a single line of code now by using the close parameter. Otherwise it's 3 lines of code. Create, read, close. When it's this simple to create your own windows you don't need modifications to popup... you can easily make your own, in-line.

I'm curious how you are going to close your window if it has no buttons an no titlebar.

@PySimpleGUI
Copy link
Owner

You can also call popup_no_buttons. This is why the button parameter exists. It's not meant to be something user accessible according to the doc string:

    :param button_type: (enum) NOT USER SET!  Determines which pre-defined buttons will be shown (Default value = POPUP_BUTTONS_OK). There are many Popup functions and they call Popup, changing this parameter to get the desired effect.

If you do use it, I recommend not setting it to a hard coded value like 5. Since it's an 'enum' the recommended way to doing it is to use POPUP_BUTTONS_NO_BUTTONS. I would suggest using the call rather than the parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants