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

PR: Add clear button to find comboboxes #5537

Merged
merged 1 commit into from
Oct 25, 2017

Conversation

timhoffm
Copy link
Contributor

@timhoffm timhoffm commented Oct 22, 2017

Fixes #5373

@ccordoba12 ccordoba12 changed the title [#5373] add clear button to find comboboxes PR: Add clear button to find comboboxes Oct 22, 2017
@ccordoba12 ccordoba12 added this to the v3.2.5 milestone Oct 22, 2017
@@ -135,6 +135,8 @@ class PatternComboBox(BaseComboBox):
def __init__(self, parent, items=None, tip=None,
adjust_to_minimum=True):
BaseComboBox.__init__(self, parent)
if hasattr(self.lineEdit(), 'setClearButtonEnabled'): # only Qt >= 5.2
Copy link
Member

Choose a reason for hiding this comment

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

Given that this only works for Qt > = 5.2, you need to enclose the lines you added in

if PYQT5:
    ...

where PYQT5 can be imported like this

from qtpy import PYQT5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The if hasattr() serves exactly that purpose: Only use this feature if available. This should work without explicity checking a Qt version.

Also, I would assume that a simple if PYQT5 would be True for 5.0 <= Qt < 5.2, but they still don't have the clear button.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, you're right, hasattr should be enough.

Besides, we only support Qt 5.2+

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides, we only support Qt 5.2+

In that case, just self.lineEdit().setClearButtonEnabled(True) would be enough.

The if is unneccesary clutter then. Should I remove it for brevity and clarity of the code?

Copy link
Member

Choose a reason for hiding this comment

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

Nop, because we also support PyQt4.

@ccordoba12 ccordoba12 requested a review from dalthviz October 23, 2017 13:51
@ccordoba12
Copy link
Member

@dalthviz, please review that this is working locally for you.

@dalthviz
Copy link
Member

@ccordoba12 I tested locally and worked for me 👍 (tested in PyQt4 and PyQt5)

@ccordoba12
Copy link
Member

Thanks @dalthviz!

@ccordoba12 ccordoba12 merged commit ac53b75 into spyder-ide:3.x Oct 25, 2017
ccordoba12 added a commit that referenced this pull request Oct 25, 2017
@timhoffm timhoffm deleted the serach-clear-button branch October 25, 2017 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants