It is hard to explain so let me present a scenario:
You are researching and have many dataframes with various names in your current session. you want to look at some dataframe you just created. printing it is rarely helpful.
Right now, I search for my dataframe in the variable explorer and open it there to have a nicer view of it.
But if I created many variables searching for the one I want becomes tedious.
What I want is the ability to have faster access to the variable by providing the variable's name.
maybe writing:
view(mydataframe)
Or having a shortcut to search all variables in variable explorer (hopefully in a fuzzy manner) and hitting Enter to view it.
Any suggestions to the tired researcher?
Cool suggestion!! We'll try to work on it for Spyder 4 :-)
Or you could give it a try for Spyder 3. We already have a fuzzy search library, so it'd be a matter of using that library with the variable explorer.
@goanpeca, what do you think? Should we try to add this in Spyder 3.2?
@ccordoba12 yep sounds like a good idea.
This would be a good moment to make the fuzzy search dialog more generic. The current one use for files makes a lot of file assumptions
I was just thinking on adding a search text box to the Variable Explorer toolbar and connecting it to the variable names.
Or add Ctrl F ?
Lets think this through a bit more. I dont want to clutter the interface.
Good idea. We could add a search icon that when pressed adds a search widget, like the one present in the Editor and consoles :-)
Hi. I was going to post an issue very similar to this one. My suggestion is the following:
1. Since the Variable Explorer do not accept typing when focused, my suggestion is that a key press could highlight the first variable that starts with that letter. If the same key is pressed again it would highlight the second occurrence and so on..
2. If "Ctrl + F" is pressed when Variable Explorer is focused, it could open a search box (maybe the same search box in the editor or a new one at the bottom of the Variable Explorer window) and filter variables that match the search text.
@jnsebgosselin, this could be a fun project for you ;-)
@ccordoba12 Alright, this definitely sounds interesting :). I will take a look into this soon.
@Prikers I said I would work on this one, but I think this might be more suitable for you since you've worked a lot on the variable explorer recently. Besides, I don't know when I'll be able to work on this one. So if you are interested, go for it :+1:
@jnsebgosselin thanks! I'll have a look at it 馃憤
I have had a first look at it and here are my first questions & findings.
case sensitive
, etc.Here is what I first came up with:
difflib.get_close_matches
get_close_matches
scoredifflib
?What you've done looks really good so far!
My thoughts:
Sorting the table was what I came up with because it avoids filtering/hidding some variables.
I'd prefer filtering/hiding. I think it feels more intuitive than sorting. @goanpeca?
Should I use something more advanced than difflib?
We have a filtering library of our own that we use to filter the keyboard shortcuts table. So we'd prefer to use that one instead:
https://github.com/spyder-ide/spyder/blob/master/spyder/utils/stringmatching.py
Are the assumptions correct?
Yep, I think they are correct. I only don't understand why you added up/down arrow buttons to the search field. It makes little sense to me.
I'd prefer filtering/hiding. I think it feels more intuitive than sorting.
I agree, it is more intuitive to hide the stuff that does not match. We could just have the textbox and the close button. Escape
key should either apply the same as the closing button or clearing the textbox.
Since this is a find like feature, we need to think of how the UI works. On the editors and console, find-like features appear on the bottom of the widget. So although this is useful I feel we are now moving in 3 separate directions.
Thanks @ccordoba12 and @goanpeca for your feedbacks.
get_search_scores
. It is slightly less fuzzy but it fits our needs here :+1: shortcuts
plugin and it seems to be doing the same thing as we are trying to achieve here. It uses a QSortFilterProxyModel
. Should I try to move in that direction? I should note that it adds a (hidden) column to the NamespaceBrowser
for the search score but as the NamespaceBrowser
comes from the ReadOnlyCollectionsModel
, it may add a hidden column to all collections table (if we want to keep the code modification relatively simple). Is that ok? I only don't understand why you added up/down arrow buttons to the search field. It makes little sense to me.
@Prikers I added that hidden column as a hack in order to achieve what we wanted. We could probably do the same for the variable explorer, but we would need to create it in the highest parent possible and yes, try to go with the proxy model. Thoughts @ccordoba12 ?
The highest parent possible would be ReadOnlyCollectionsModel
. It is a QAbstractTableModel
.
Very good job.
Please also consider my previous suggestion to add a quick navigation through the variables:
- Since the Variable Explorer do not accept typing when focused, my suggestion is that a key press could highlight the first variable that starts with that letter. If the same key is pressed again it would highlight the second occurrence and so on.
@yuribr84, your suggestion is hard to implement and it provides essentially the same functionality of the search bar, so I don't agree with it it too much.
@yuribr84 what you are suggesting is already kind of possible: if you sort the variable explorer table by variable name and then hit any letter key, it will highlight the first variable that starts with this key. The other variables starting with this key are then following as the table has been sorted.
I know it is not obvious but as @ccordoba12 mentioned it will be complicated to implement something more user-friendly for this use-case.
hello,
if i am not wrong you are talking to add some search/filtering options in the variable explorer. I would like to propose something more: search and filtering inside these variables. this would be very useful when using database as pandas where a single variable could contain thousands, or more, things
maybe i wasn't very clear so here there is an example from R Studio under filtering and searching, also the "advanced topics" is interesting
Most helpful comment
I have had a first look at it and here are my first questions & findings.
Assumptions
case sensitive
, etc.First thoughts
Here is what I first came up with:
difflib.get_close_matches
get_close_matches
scoreExample
Questions
difflib
?