-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add Icons to Completions #2337
Add Icons to Completions #2337
Conversation
diff --git a/spyderlib/widgets/sourcecode/base.py b/spyderlib/widgets/sourcecode/base.py index 6a2ea25..6dd304d 100644 --- a/spyderlib/widgets/sourcecode/base.py +++ b/spyderlib/widgets/sourcecode/base.py @@ -72,19 +72,17 @@ class CompletionWidget(QListWidget): self.completion_list = completion_list self.clear() - lut = dict(instance='class.png', method='method.png', - function='function.png', attribute='attribute.png') + lut = dict(instance='attribute.png', method='method.png', + statement='attribute.png', function='function.png', + attribute='attribute.png') + lut['class'] = 'class.png' for (c, t) in zip(completion_list, types): - if t in lut: - self.addItem(QListWidgetItem(get_icon(lut[t]), c)) - elif t == 'class': - self.addItem(QListWidgetItem(get_icon(lut['instance']), c)) - else: - self.addItem(c) + icon = lut.get(t, 'no_match.png') + self.addItem(QListWidgetItem(get_icon(icon), c)) self.setCurrentRow(0) - + QApplication.processEvents(QEventLoop.ExcludeUserInputEvents) self.show() self.setFocus()
Note that neither Jedi nor Rope return |
That means that methods will be listed as functions? or? What about the privacy of the elements, anything to also have that? |
Methods are listed as functions. The privacy can be inferred from the name, but the type cannot. I say the less icons the better. |
Seems fine for now. It would be great to only display matching options instead of the full list |
That is for another PR. |
Indeed |
Cool, cool, really cool!! I've wanted to have this for years!! |
A note about the new icons here: please add them to our LICENSE file :-) |
completions = self.get_jedi_object('completions', info) | ||
debug_print(str(completions)[:100]) |
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.
Why did you remove this debug_print
here? Just curious, I don't know how important that is.
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.
Do you plan to remove or leave this debug_print
? You haven't answered my question :-)
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.
Fixed now, with updated info!
Ok, first review done. |
@ccordoba12, comments addressed. |
I can make a new set of icons (pngs.) for this after merged, I am ok doing that (now I have some xp), so @blink1073 can focus on functionality and not on looks, ok? My idea of the privacy is not to include more icons (indeed can become confusing), the point is that if we can for now return that info we could eventually use it to make some things... like never display super private methods in completion outside the module they are defined (as an option in the global preferences), or only display private methods if you are inside the actual class defining them. Also maybe Python special methods should be always on top? |
I don't see a need to get any more complicated than what we have. The underscore methods are moved to the bottom by default because you are more often looking for other attributes. Also, Python is built on the "we're all consenting adults" mantra, which arbitrarily hiding private methods would go against that. |
ok |
On the icons I meant for the current ones, which look pixelated... I do not intend to make new icons, but make the existing ones more uniform. |
@goanpeca or just make bitmap versions of the new qtawesome ones, once I made them pixel perfect. |
self.completion_list = completion_list | ||
self.clear() | ||
self.addItems(completion_list) | ||
|
||
icon_lut = {'instance': 'attribute.png', |
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.
What does lut
mean? I don't get it :-)
What about renaming this variable for icons_map
?
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.
Ha! lut == look up table. I'll change it.
Other than my minor remarks, this is ready to merge! Great work @blink1073!! |
And I think I'm done. |
Let's wait for Travis before merging :-) |
Add icons to code completions on the Editor
Fixes #2327.