- Notifications
You must be signed in to change notification settings - Fork 750
Add button_dialog, including docs/examples #583
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
Conversation
Codecov Report
@@ Coverage Diff @@ ## 2.0 #583 +/- ## ========================================== - Coverage 71.06% 71.04% -0.02% ========================================== Files 123 123 Lines 11926 11932 +6 ========================================== + Hits 8475 8477 +2 - Misses 3451 3455 +4
Continue to review full report at Codecov.
|
9e27a8f to d18ed24 Compare | Sorry, but I don't have any idea how to write tests for this... But it works! |
d18ed24 to 67da8ce Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sreyemnayr,
Thank you for this. Very cool! I have two small remarks (see review), but when that's fixed, it's fine for me.
Right now, none of the dialog functions has unit tests. Actually, we should add them (it would be possible with a DummyOutput and PipeInput, like in tests/test_cli.py), but for now, don't worry too much about that.
docs/pages/dialogs.rst Outdated
| result = button_dialog( | ||
| title='Button dialog example', | ||
| text='Do you want to confirm?', | ||
| buttons=( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this a list of tuples?
See also this page for more about the difference: https://nedbatchelder.com/blog/201608/lists_vs_tuples.html
Also, I like spaces after the commas in the tuples. ;)
examples/dialogs/button_dialog.py Outdated
| @@ -0,0 +1,24 @@ | |||
| #!/usr/bin/env python | |||
| """ | |||
| Example of confirmation (yes/no) dialog window. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix this docstring?
52858fc to debbf4f Compare | Done! Truthfully, the yes_no_dialog could just call the button_dialog now to maintain DRY... |
| Thanks a lot for this! It's very much appreciated. Feel free to create another merge request to rewrite It also reminds me that I should fix the background of the buttons when they are selected. I removed the 'focussed' class from the style in the Cheers! |
| I was actually going to ask you how to do this! …________________________________ From: Jonathan Slenders <notifications@github.com> Sent: Wednesday, February 7, 2018 3:21:17 PM To: jonathanslenders/python-prompt-toolkit Cc: sreyemnayr; Mention Subject: Re: [jonathanslenders/python-prompt-toolkit] Add button_dialog, including docs/examples (#583) Thanks a lot for this! It's very much appreciated. Feel free to create another merge request to rewrite yes_no_dialog building on top of this. It also reminds me that I should fix the background of the buttons when they are selected. I removed the 'focussed' class from the style in the Window because that was not the right place to add this, but it should be added somewhere else. Cheers! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#583 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIKYTldRKW-FrZW9K7Oop3eIoapNr8dkks5tShPNgaJpZM4R7a7L>. |
| See here: 3c8a29e |
| Nice! I’ll knock that yes_no_dialog piece out in a bit. Such a cool project, I’m honored to contribute! Ryan Meyers …________________________________ From: Jonathan Slenders <notifications@github.com> Sent: Wednesday, February 7, 2018 4:11:54 PM To: jonathanslenders/python-prompt-toolkit Cc: sreyemnayr; Mention Subject: Re: [jonathanslenders/python-prompt-toolkit] Add button_dialog, including docs/examples (#583) See here: 3c8a29e<3c8a29e> — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#583 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIKYTg0c5xFhYitRzumNH5-5RIqF2qJvks5tSh-qgaJpZM4R7a7L>. |
Provides the ability to render several buttons with values of your choosing.

Updated docs and examples to show how it works.