I want to remove the "Ok" button packed by default with my simple popup (using popup with no title bar).
Arch Linux
3.8.1
4.15.2
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)?
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
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.
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.
Most helpful comment
Found the solution by taking a look at source code (psg).
Just provide the
button_type
argument like this:In PySimpleGUI there are 5 types of button configurations: