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: Modify color scheme preferences #2861

Closed
wants to merge 19 commits into from
Closed

PR: Modify color scheme preferences #2861

wants to merge 19 commits into from

Conversation

goanpeca
Copy link
Member

@goanpeca goanpeca commented Dec 8, 2015

Related to #820

Description

This PR aims to simplify the user experience for editing the color schemes.
It also incorporates the creation/deletion of an unlimited number of custom schemes.

This PR however does not (yet) add the custom schemes to the options in the other plugins (editor etc...) as the idea is to unify the different color schemes into a single global one, located in this updated preferences page. This will be accomplished in a subsequent PR.

The custom name is generated automatically (custom-N) but are modifiable. For default schemes colors are modifiable, but the scheme name is not.

Final Screenshots

image

image

@goanpeca goanpeca added this to the V3.0beta3 milestone Dec 8, 2015
@goanpeca
Copy link
Member Author

goanpeca commented Dec 8, 2015

Initial screenshots

channels and 3

channels and 4

@Nodd, @SylvainCorlay, @blink1073 comments are welcome

@@ -162,6 +162,3 @@ def set_default_color_scheme(name, replace=True):

for _name in sh.COLOR_SCHEME_NAMES:
set_default_color_scheme(_name, replace=False)
CUSTOM_COLOR_SCHEME_NAME = "Custom"
set_color_scheme(CUSTOM_COLOR_SCHEME_NAME, sh.get_color_scheme("Spyder"),
replace=False)
Copy link
Member Author

Choose a reason for hiding this comment

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

There is no point in having a custom scheme now

Copy link
Member

Choose a reason for hiding this comment

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

Ok, no problem with that :-)

@blink1073
Copy link
Contributor

I love the comments on your own PR, very schizophrenic. I am +100 on this change.

@goanpeca
Copy link
Member Author

goanpeca commented Dec 8, 2015

Hehe, I wanted to save some time, and I was almost sure someone had something to say in that respect,

Would you mind testing it @blink1073 ?

@ccordoba12
Copy link
Member

A couple of quick suggestions:

  1. I don't like the Create new scheme button to expand the two columns. I'd like to see it at the bottom but only on the left column (i.e. the buttons column :-)
  2. In the dropdown menu please change Scheme to Scheme:

@goanpeca
Copy link
Member Author

goanpeca commented Dec 8, 2015

👍

@Nodd
Copy link
Contributor

Nodd commented Dec 8, 2015

The first thing I thought when viewing the screenshots is that the preview is really a great addition. Just the line numbers are missing.

About the edition of the colors, the entries should be grouped differently, ideally with many group widgets. The minimum would be to group the text values together so that the checkboxes are not all over the place. One group for "text" and one for "background" for example. Or "text", "text highlighting" and "background".

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

Look update

@ccordoba12, and for @Nodd ... numbers

image

@Nodd
image


Plus now we have instant preview, so any changes on an edited theme will reflect in the preview right away (without the need to apply the changes)

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

It is looking pretty good already, but I guess the final touch would be to have the preview in the editor dialog, and have it update in every single change inside the actual dialog.

What do you think?

@Nodd
Copy link
Contributor

Nodd commented Dec 9, 2015

Here is my habitual flow of nitpicks:

  • Maybe current cell and current line should be in the Background group, since the are applied to blocks of code and not particular words or characters.
  • Background group could be before Highlight group since it's more general (not sure about this one)
  • Normal text should be on top
  • builtin and keyword should be next of each other

having the preview in the same dialog would be nice too, but you could also put the edition widgets in the main panel next to the current preview. Maybe it's too big to be practical, I'm not sure.

There is too much space between the "Preview" label and the preview widget, I'd completely remove the label since it's already quite obvious.

self.preview_editor.setup_editor(linenumbers=True,
markers=False,
tab_mode=False,
font=QFont("Courier New", 10),
Copy link
Contributor

Choose a reason for hiding this comment

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

The font should not be hard coded, the configured fond should be used instead.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@Nodd
Copy link
Contributor

Nodd commented Dec 9, 2015

After a very quick overview of the code, it seems that all the definitions are stored in the main configuration file. Ideally each scheme should be in its own file so that it's easier to share, but I'd leave that for another PR (along with import/export)

@ccordoba12
Copy link
Member

I guess the final touch would be to have the preview in the editor dialog

It's fine where it is for me. I think few people will go into the trouble of customizing themes, but most will like to see what a theme looks like instead.


Maybe current cell and current line should be in the Background group

I don't know about this one, but I agree with the other @Nodd suggestions.

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

@Nodd, as usual thanks for being a pain in the (_!_)

  • Maybe current cell and current line should be in the Background group, since the are applied to blocks of code and not particular words or characters.

I do not agree, cause the idea is to have a highlight group.... independent of what it highlights

  • Background group could be before Highlight group since it's more general (not sure about this one)

I am not sure what general mean? you mean it would be changed more often?

  • Normal text should be on top builtin and keyword should be next of each other

Sure, it make sense, I was waiting for you to give me the full order, I just grouped them together...

  • There is too much space between the "Preview" label and the preview widget, I'd completely remove the label since it's already quite obvious.

Sure

having the preview in the same dialog would be nice too, but you could also put the edition widgets in the main panel next to the current preview. Maybe it's too big to be practical, I'm not sure.

No no no no and no, the idea was to take away so much visual noise from the user when selecting, a theme. The casual user really just selects a default, a power user would either import one, or make one.

The edition dialog is already too large to bring it back to the main menu.

After a very quick overview of the code, it seems that all the definitions are stored in the main configuration file. Ideally each scheme should be in its own file so that it's easier to share, but I'd leave that for another PR (along with import/export)

👎

To do this I think we need a common use color schemes format, which probably exists and stores stuff as XML or JSON, that is the point of having the Export options, so that you can share them in any format we decide to support, that will come in another PR when those "standards" are pointed out by someone. Any preferences in Spyder is built on the CONF idea, which makes life easy, but restricts us to keep using it, so having separate files would be another layer of possible bugs...

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

@Nodd, @ccordoba12

Look update

image

image

@blink1073
Copy link
Contributor

I would leave out the create new button for now, and leave that for another PR, as it is just inviting confusion at the moment. Otherwise, I am 👍 for merging and iterating.

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

@blink1073, I will remove the button but leave the code that does the work ok, as it is perfectly functional?

@blink1073
Copy link
Contributor

Yep, makes sense to me.

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

@blink1073 by the way did you actually test it :-p ?

@blink1073
Copy link
Contributor

Yes, hence my comment about it being confusing :)

@goanpeca
Copy link
Member Author

goanpeca commented Dec 9, 2015

@blink1073 was having some issues with the dialog being too tall, so now is a two columns layout

image

@blink1073
Copy link
Contributor

Perfect, thank you, I am no longer confused. :)

@Nodd
Copy link
Contributor

Nodd commented Dec 10, 2015

My main concern about the config file full of everything is that when there is a problem in the config we have to reset everything. I'd bet that it's not the color definitions that will cause spyder to fail, but they will be reset anyway along everything else.
Way too many issues are solved by spyder --reset, we have something to solve here (on the long term).

It's very nice on 2 columns, but actually I'd change the order again (sorry, I was on my phone before):

  • Normal text
  • Comment
  • String
  • Number
  • Keyword
  • Builtin
  • Definition
  • Instance (should be renamed to self, or do whe use this color for something else ?)
  • Current cell
  • Current line
  • Occurrence
  • Matched parens
  • Unmatched parens
  • Link

I agree that technically cells and current line are highlighted by the color, but when working on code it's more of a general visual help rather than an important information about what I'm doing in my code. I don't want to start a big debate, as putting them in highlight works too.

# Checks that this is indeed a default scheme
scheme = self.current_scheme
names = self.get_option('names')
if scheme not in names:
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be if scheme in names: ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I made a mistake :-)

@goanpeca
Copy link
Member Author

@ccordoba12 made the fixes, thanks for the review


def set_scheme(self, scheme_name):
"""
Set the current stack in the dialog to the scheme with 'schema_name'.
Copy link
Member

Choose a reason for hiding this comment

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

Typo here: schema_name -> scheme_name

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@ccordoba12
Copy link
Member

There's one little error I discovered with live testing: even though you can change a custom scheme name in the scheme editor dialog, that name is not reflected in the schemes combo box of the new preferences pages.

I think it should be changed there too :-)

@goanpeca
Copy link
Member Author

@ccordoba12 fixed the issue and related comments

@goanpeca
Copy link
Member Author

@ccordoba12 merged with master....

@ccordoba12
Copy link
Member

I can't open our Preferences after your update. This is the traceback

Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/spyder.py", line 2614, in edit_preferences
    widget.initialize()
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 70, in initialize
    self.setup_page()
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 995, in setup_page
    self.update_combobox()
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1030, in update_combobox
    self.scheme_choices_dict[self.get_option('{0}/name'.format(n))] = n
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 49, in get_option
    return CONF.get(self.CONF_SECTION, option, default)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/config/user.py", line 380, in get
    raise cp.NoOptionError(option, section)
ConfigParser.NoOptionError: No option 'Custom/name' in section: 'color_schemes'

@goanpeca
Copy link
Member Author

@ccordoba12 I dont get that error, can you reset your ini ???

There used to be a Custom thing but the ini changed version to change this default....

Should not it be getting that change in version? Should I bump to 25 the version then?

@goanpeca
Copy link
Member Author

goanpeca commented Feb 1, 2016

@ccordoba12 ?

def setup_page(self):
tabs = QTabWidget()
names = self.get_option("names")
Copy link
Member

Choose a reason for hiding this comment

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

Add here names.pop(names.index(u'Custom'))

@ccordoba12
Copy link
Member

I added as comments how to fix the bug I'm seeing. The problem is the old Custom scheme has not name attribute (added by you to the other schemes). And Custom is returned as a valid scheme name when you use names = self.get_option('names'), if you are coming from 2.3.

I think the best thing to do (as I did) is to remove Custom from names. Another option would be to remove all Custom/* options from users spyder.ini. But that can't be done by a bump in CONF_VERSION because there is no Custom section in conf/main.py. Besides, removing those options must be done once and only once.

Of course, a potential problem will occur if a user decides to name a color scheme Custom :-s

@goanpeca
Copy link
Member Author

goanpeca commented Feb 1, 2016

@ccordoba12 thanks for the suggested fix.

There is no potential problem, 'cause all the custom names are stored in a different key.

@ccordoba12
Copy link
Member

Oh yeah! But now I'm seeing this error when trying to create a new scheme:

Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1081, in update_preview
    scheme_name = self.current_scheme
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1016, in current_scheme
    return self.scheme_choices_dict[self.current_scheme_name]
KeyError: u''
Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1055, in update_buttons
    current_scheme = self.current_scheme
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1016, in current_scheme
    return self.scheme_choices_dict[self.current_scheme_name]
KeyError: u''

@ccordoba12
Copy link
Member

And this error when trying to delete it (after closing and opening Preferences again after the error mentioned above):

Traceback (most recent call last):
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1158, in delete_scheme
    self.set_scheme('spyder')
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1182, in set_scheme
    dlg.set_scheme(scheme_name)
  File "/home/carlos/Projects/spyder/github-repo/spyderlib/plugins/configdialog.py", line 1231, in set_scheme
    self.stack.setCurrentIndex(self.order.index(scheme_name))
ValueError: 'spyder' is not in list

@goanpeca
Copy link
Member Author

goanpeca commented Feb 1, 2016

Are this errors because of the changes you suggested?

@ccordoba12
Copy link
Member

I don't think so. My changes only remove Custom as a possible scheme. These errors are in your code.

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.

4 participants