revamping vanilla dialogs
for now only askYesNo and askYesNoCancel are available
https://github.com/robotools/vanilla/blob/master/Lib/vanilla/dialogs.py
Im in favour of adding def ask(...) which is the most generic method askYesNo is a bit more specific.
ask(
"message",
"info",
altertStyle="critical",
buttons=[dict(title="Yes", callback=yesCallback), dict("Nooooooooooo", callback=nooooooooCallback) ]
)
also add:
- accessoryView
- icon
- showsHelp
- use string identifiers for alert styles:
-
informational -
critical - `warning
-
both the alert style as the button titles should be backward compatible
Yes, love this.
A couple of things on ask:
- Should the displayed buttons follow the order of the items in the button title list?
If my button titles are:
buttonTitles=[
dict(title="A", returnCode=1),
dict(title="B", returnCode=2),
dict(title="C", returnCode=3),
dict(title="D", returnCode=4),
dict(title="E", returnCode=5)
],
They will be shown to the user as [E D C B A]. Maybe it's logical? It confused me at first.
- I'd like to be able to control the default button and add a key command.
-
default: True | False (False is the default) -
keyCommand: Same structure as Button.bind
These are discussed in the addButtonWithTitle documentation.
I can write this code. I just want to make sure it's an okay idea.
-
The order is keept as it was before this changes, which is indeed reversed.
-
The Default button is just the first one... when a button has "Cancel" as title it will have a key equivalent of esc, same for "Don't Save" with cmd-D see https://developer.apple.com/documentation/appkit/nsalert/1532992-buttons?language=objc
having an optional "default" and "keyCommand" would be super useful!
addButtonWithTitle returns the NSButton object which can be used to change the its behaviour
I already added "callback" as option, which is called when the button is hit
Can we close this?
Yes.