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

feat: Change icon used in Collapsible widget #140

Merged
merged 20 commits into from
Dec 1, 2022

Conversation

ppwadhwa
Copy link
Contributor

@ppwadhwa ppwadhwa commented Nov 17, 2022

This PR adds the ability to change the icon on the toggle QPushButton. Currently, the icon is a part of the text string. This PR will change it so that an icon is set on the button. The original icon is still used if there isn't one set, however, the default string is used to create an icon.

You can now instantiate a collapsible widget while also declaring an expandedIcon and/or collapsedIcon. These icons can be a QIcon or a text string.

icon1 = icon(FA5S.smile, color='white')
icon2 = icon(FA5S.frown, color='white')
collapsible = QCollapsible("Advanced analysis", expandedIcon=icon1, collapsedIcon=icon2)

Screen Shot 2022-11-21 at 4 14 03 PM

Screen Shot 2022-11-21 at 4 14 11 PM

collapsible = QCollapsible("Advanced analysis", expandedIcon='-', collapsedIcon="+")

Screen Shot 2022-11-21 at 4 16 53 PM

Screen Shot 2022-11-21 at 4 16 46 PM

@ppwadhwa ppwadhwa marked this pull request as draft November 17, 2022 15:27
@@ -11,16 +20,16 @@ class QCollapsible(QFrame):
Based on https://stackoverflow.com/a/68141638
"""

_EXPANDED = "▼ "
_COLLAPSED = "▲ "

def __init__(self, title: str = "", parent: Optional[QWidget] = None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should maybe also expose the collapsedIcon and the expandedIcon as Optional arguments (as some buttons allow in Qt)?

What do you think @tlambert03 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this.

Copy link

@goanpeca goanpeca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ppwadhwa thanks for working on this! Great work 🚀

Added some comments to clean up the code a bit :)

@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Base: 85.30% // Head: 85.43% // Increases project coverage by +0.13% 🎉

Coverage data is based on head (cbe4cdc) compared to base (ad2f05d).
Patch coverage: 98.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
+ Coverage   85.30%   85.43%   +0.13%     
==========================================
  Files          31       31              
  Lines        2573     2603      +30     
==========================================
+ Hits         2195     2224      +29     
- Misses        378      379       +1     
Impacted Files Coverage Δ
src/superqt/collapsible/_collapsible.py 94.78% <98.00%> (+0.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ppwadhwa
Copy link
Contributor Author

OK. I see I need to fix the tests. Will get to this....

@ppwadhwa ppwadhwa force-pushed the collapsible_change_icon branch from b2e66b7 to dc2866d Compare November 23, 2022 19:43
@ppwadhwa ppwadhwa marked this pull request as ready for review November 26, 2022 08:55
@ppwadhwa ppwadhwa force-pushed the collapsible_change_icon branch from 9ce54d2 to d451e58 Compare November 28, 2022 21:57
Copy link

@goanpeca goanpeca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @ppwadhwa, works great 🚀

@ppwadhwa ppwadhwa requested a review from tlambert03 November 29, 2022 19:33
@goanpeca
Copy link

goanpeca commented Nov 29, 2022

🤔

tox: py310-macos-pyqt5
  py310-macos-pyqt5 inst: /tmp/.tox/.tmp/package/1/superqt-0.1.dev1+g1a34dcc.tar.gz
  Error: The action has timed out.

This one is ready for review @tlambert03 :) Thanks!

@tlambert03
Copy link
Member

good stuff. thanks both!

@tlambert03 tlambert03 changed the title Change icon used in Collapsible widget feat: Change icon used in Collapsible widget Dec 1, 2022
@tlambert03 tlambert03 added the enhancement New feature or request label Dec 1, 2022
@tlambert03 tlambert03 merged commit 7b2d8bf into pyapp-kit:main Dec 1, 2022
@goanpeca
Copy link

goanpeca commented Dec 1, 2022

Thanks for the quick review 🤭

@tlambert03 do you think you could make a new release with the latest changes sometime soon :) ?

Thanks for the awesome project!

@tlambert03
Copy link
Member

Yep 👍 will do tomorrow

@ppwadhwa
Copy link
Contributor Author

ppwadhwa commented Dec 1, 2022

thanks @tlambert03 !!!

@tlambert03
Copy link
Member

v0.4.1 building now... should be up soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants