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: Patch QFiledialog and offer new methods #122

Closed
wants to merge 2 commits into from

Conversation

goanpeca
Copy link
Member

Fixes #26

@goanpeca goanpeca added this to the v1.3 milestone Jul 31, 2017
@goanpeca goanpeca self-assigned this Jul 31, 2017
@goanpeca goanpeca requested review from ccordoba12 and Nodd July 31, 2017 21:46
@goanpeca
Copy link
Member Author

@Nodd better late than never. So this patch exposes the methods with Qt case, plus a 2, because they change the return values. So changing compatibility for existing code, is just adding a 2 and accepting a tupple instead of a single argument.

Thoughts @ccordoba12 ?

QFileDialog.getOpenFileName2 = _getOpenFileName
QFileDialog.getOpenFileNames2 = _getOpenFileNames
QFileDialog.getSaveFileName2 = _getSaveFileName
QFileDialog.getExistingDirectory2 = _getExistingDirectory
Copy link
Member

Choose a reason for hiding this comment

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

Do these names exists in Qt? I mean, getOpenFileName2, etc?

Copy link
Member Author

@goanpeca goanpeca Jul 31, 2017

Choose a reason for hiding this comment

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

No they don't, but if we replace the normal methods, the return is changed, so it would be weird.

We can warn QFileDialog.getExistingDirectory to better use QFileDialog.getExistingDirectory2.

Unfortunately I cant run any test on this, cause I am either stuck in the exec loop or segfaulting (which points to the bigger problem of using these methods :-|). I think that in general is a very bad idea/bad practice to use this methods that call exec/modal directly. It is better and safer (as seen by the latest fixes of @rlaverde in spyder) to avoid using these methods :-\

Copy link
Member Author

Choose a reason for hiding this comment

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

RuntimeError: no access to protected functions or signals for objects not created from Python there is no way to add tests for this PR cause testing methods that call exec block testing, even if I try to access them by name, I will not be able to call the methods.

@ccordoba12
Copy link
Member

Tests are failing.

@goanpeca
Copy link
Member Author

Tests are failing.

Wow really??!?! thanks for letting me know 😈

@ccordoba12
Copy link
Member

Jeje, just in case you haven't noticed it ;-p

@goanpeca
Copy link
Member Author

goanpeca commented Aug 1, 2017

Yeah, this is definitely not testable. I would say we should not really encourage the use of the compat funcs. And we should warn the user when using methods that do not create python objects the user can access or interact with (QMessageBox and QFileDialog methods).

Thoughts @ccordoba12 ?

@ccordoba12
Copy link
Member

Yeah, this is definitely not testable

Ok, no problem with that.

However, I don't agree too much with the addition of warnings in this PR because we will have to add code in Spyder to swallow them.

@ccordoba12 ccordoba12 modified the milestones: v1.3.1, v1.3 Aug 1, 2017
@goanpeca
Copy link
Member Author

goanpeca commented Aug 1, 2017

However, I don't agree too much with the addition of warnings in this PR because we will have to add code in Spyder to swallow them.

Yes, I can remove it for now. My point is that we should move away from using those methods in Spyder as we cannot test them plus they sometimes lead to odd segfaults. It is always better to create the object first and then exec it (but we have the reference to the python object and can interact with it if needed on tests or avoid segfaults) like https://github.com/spyder-ide/spyder/pull/4870/files#diff-0308a6d064ae2a204bd97de4f832e1f4R1430

@ccordoba12 ccordoba12 modified the milestones: v1.3.1, v1.4 Aug 19, 2017
@ccordoba12
Copy link
Member

@goanpeca, could you finish this PR?

@ccordoba12 ccordoba12 modified the milestones: v1.4, v1.5 Mar 11, 2018
@ccordoba12 ccordoba12 modified the milestones: v1.5, v2.0 Jun 11, 2018
@cpascual
Copy link
Contributor

cpascual commented Oct 1, 2018

I personally think that qtpy should not patch the imported Qt objects. The rationale is the same as I already expressed in #119 : side effects for people not even using qtpy should be avoided at all costs.

For example, with this PR an application using perfectly valid PyQt4 code could break just because it imported a widget from spyder

@ccordoba12 ccordoba12 removed this from the v2.0 milestone Oct 1, 2018
@ccordoba12
Copy link
Member

Ok, let's close this for now due to @cpascual's remarks and this being stalled.

@ccordoba12 ccordoba12 closed this Oct 1, 2018
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