Skip to content

Conversation

@sreyemnayr
Copy link
Contributor

Provides the ability to render several buttons with values of your choosing.
Updated docs and examples to show how it works.
button

@codecov-io
Copy link

codecov-io commented Feb 6, 2018

Codecov Report

Merging #583 into 2.0 will decrease coverage by 0.01%.
The diff coverage is 42.85%.

Impacted file tree graph

@@ 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
Impacted Files Coverage Δ
prompt_toolkit/shortcuts/__init__.py 100% <100%> (ø) ⬆️
prompt_toolkit/shortcuts/dialogs.py 28.94% <33.33%> (+0.37%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3c59f3...debbf4f. Read the comment docs.

@sreyemnayr
Copy link
Contributor Author

Sorry, but I don't have any idea how to write tests for this... But it works!

Copy link
Member

@jonathanslenders jonathanslenders left a 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.

result = button_dialog(
title='Button dialog example',
text='Do you want to confirm?',
buttons=(
Copy link
Member

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. ;)

@@ -0,0 +1,24 @@
#!/usr/bin/env python
"""
Example of confirmation (yes/no) dialog window.
Copy link
Member

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?

@sreyemnayr
Copy link
Contributor Author

Done! Truthfully, the yes_no_dialog could just call the button_dialog now to maintain DRY...
Glad to have been able to contribute (and to learn about functools.partial today) :)

@jonathanslenders jonathanslenders merged commit 202f20b into prompt-toolkit:2.0 Feb 7, 2018
@jonathanslenders
Copy link
Member

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!

@sreyemnayr
Copy link
Contributor Author

sreyemnayr commented Feb 7, 2018 via email

@jonathanslenders
Copy link
Member

See here: 3c8a29e

@sreyemnayr
Copy link
Contributor Author

sreyemnayr commented Feb 7, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants