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

Add Icons to Completions #2337

Merged
merged 10 commits into from
Apr 22, 2015
Merged

Conversation

blink1073
Copy link
Contributor

Fixes #2327.

screen shot 2015-04-17 at 9 56 02 pm

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()
@blink1073
Copy link
Contributor Author

Note that neither Jedi nor Rope return method as a type, only function.

@goanpeca
Copy link
Member

That means that methods will be listed as functions? or?

What about the privacy of the elements, anything to also have that?

@blink1073
Copy link
Contributor Author

Methods are listed as functions. The privacy can be inferred from the name, but the type cannot. I say the less icons the better.

@goanpeca
Copy link
Member

Seems fine for now. It would be great to only display matching options instead of the full list

@blink1073
Copy link
Contributor Author

That is for another PR.

@goanpeca
Copy link
Member

Indeed

@ccordoba12
Copy link
Member

Cool, cool, really cool!! I've wanted to have this for years!!

@ccordoba12
Copy link
Member

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])
Copy link
Member

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.

Copy link
Member

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 :-)

Copy link
Contributor Author

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!

@ccordoba12
Copy link
Member

Ok, first review done.

@blink1073
Copy link
Contributor Author

@ccordoba12, comments addressed.

@goanpeca
Copy link
Member

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?

@blink1073
Copy link
Contributor Author

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.

@goanpeca
Copy link
Member

ok

@goanpeca
Copy link
Member

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.

@SylvainCorlay
Copy link
Member

@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',
Copy link
Member

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?

Copy link
Contributor Author

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.

@ccordoba12
Copy link
Member

Other than my minor remarks, this is ready to merge!

Great work @blink1073!!

@blink1073
Copy link
Contributor Author

And I think I'm done.

@ccordoba12
Copy link
Member

Let's wait for Travis before merging :-)

ccordoba12 added a commit that referenced this pull request Apr 22, 2015
Add icons to code completions on the Editor
@ccordoba12 ccordoba12 merged commit f72a64d into spyder-ide:master Apr 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add icons to completions
4 participants