Spyder: Add a menu entry to select between available color schemes

Created on 27 Nov 2018  Â·  36Comments  Â·  Source: spyder-ide/spyder

Issue Report Checklist

  • [x] Searched the issues page for similar reports
  • [x] Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • [x] Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • N/A Could not reproduce inside jupyter qtconsole (if console-related)
  • N/A Tried basic troubleshooting (if a bug/error)
  • [x] Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

I generally prefer working with a dark background on the editor (I use the Spyder Dark colour scheme). However, when working with others or showing work on a big screen / projector, it's useful to have a quick method of switching to a light background (e.g. Spyder colour scheme). It would be really nice if a keyboard shortcut could be set up to switch between two specified colour schemes.

What steps reproduce the problem?

  1. Go to keyboard shortcuts configuration page
  2. Search in vain for anything colour scheme related
  3. 3.

Versions

  • Spyder version: 3.3.1
  • Python version: 3.7.1
  • Qt version: 5.6.2
  • PyQt version: 5.6
  • Operating System name/version: Windows 10

(P.S. If you're suggesting in the template that people go to Help...About Spyder for this information, it would be really nice if it was copy-able for pasting in here rather than having to type it and risk making a mistake)

Dependencies

IPython >=4.0     :  7.1.1 (OK)
cython >=0.21     :  0.29 (OK)
jedi >=0.9.0      :  0.13.1 (OK)
matplotlib >=2.0.0:  2.2.2 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
numpy >=1.7       :  1.15.3 (OK)
pandas >=0.13.1   :  0.23.4 (OK)
pycodestyle >=2.3 :  2.4.0 (OK)
pyflakes >=0.6.0  :  2.0.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
pylint >=0.25     :  2.1.1 (OK)
qtconsole >=4.2.0 :  4.4.2 (OK)
rope >=0.9.4      :  0.11.0 (OK)
sphinx >=0.6.6    :  1.8.1 (OK)
sympy >=0.7.3     :  1.3 (OK)
Editor Enhancement future

All 36 comments

There's no single dark nor light background, so it's not possible that we decide that for users. However, an alternative would be to add an entry to the Source menu with all color schemes available so users can easily select from them.

How does that sound?

Would it then be possible to add a shortcut key for any of the entries? I
could then have a shortcut key for my chosen light scheme and another one
for a dark scheme, which would be almost as good as a toggle key.

Thanks,

Al

On Tue, 27 Nov 2018 at 12:38, Carlos Cordoba notifications@github.com
wrote:

There's no single dark nor light background, so it's not possible that we
decide that for users. However, an alternative would be to add an entry to
the Source menu with all color schemes available so users can easily
select from them.

How does that sound?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/8317#issuecomment-442043663,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAo7j3RJuj1fNHcphkyLUv4-5-x11kJ9ks5uzTJCgaJpZM4Y03ZV
.

--
http://www.cgtk.co.uk

(P.S. If you're suggesting in the template that people go to Help...About Spyder for this information, it would be really nice if it was copy-able for pasting in here rather than having to type it and risk making a mistake)

Please see https://github.com/spyder-ide/spyder/issues/7844

There's no single dark nor light background, so it's not possible that we decide that for users. However, an alternative would be to add an entry to the Source menu with all color schemes available so users can easily select from them.

I support this idea. With this solution, you would be able in Windows to quickly and easily press Ctrl-C to select the desired scheme. This would be very convenient.

I don't understand how to implement it, so help is welcome here.

@ccordoba12 maybe I was not clear. I support your idea of adding an entry to the Source menu.

I'm not sure adding yet another keyboard shortcut for this is a good idea...

Hi, I'll start working on this. Can I try to implement this on Spyder 4? Or it has to be on Spyder 3?
Thanks in advance!

Thanks! Every new work has to be done for Spyder 4 (Spyder 3 will only receive critical bugfixes from now on).

Thanks! Every new work has to be done for Spyder 4 (Spyder 3 will only receive critical bugfixes from now on).

@ccordoba12 to solve this problem, you want a specific keyboard shortcut or a entry in the Source menu?

No, no keyboard shortcuts. Just showing the color schemes users can select from in a submenu.

Oh, one thing, I don't really remember Spyder 3, but on Spyder 4, you can not only change the editor background and style(from pre-selected themes or creating a new one), but also the interface theme (Light or Dark). The suggestion is for changing which of those? Cause changing interfaces requires a restart, and changing syntax themes does not, so i'm supposing the new shortcut is for changing syntax themes right?

Yes, it's for changing syntax themes, but we don't want a shortcut but a menu entry in Sources.

Yes yes, sorry, I ment shortcut in the Sources menu

As discussed in PR #8426 and emphasized by @CAM-Gerlach, adding a submenu with a list of all available color schemes to the Source menu is not really addressing this issue, so I think we need to discuss this a little bit further here before going forward with a solution.

From PR https://github.com/spyder-ide/spyder/pull/8426#issuecomment-447191759 :

I'm not a developer, but just a normal user. From my using scenario, it'll be helpful to have a submenu to switch color schemes (without considering the implementation or delay detail), but it won't hurt without it. I can change that via preferences, and an even better thing is I can preview the effect via preferences.

What will be very helpful is a convenient way to switch between dark mode and light mode by user base on the time or the environment. Maybe one can select one color scheme as the default light mode and one as the default dark mode.

Thank you @gepcel for your input on this. Another idea would be to add an action to the source menu that switch to last used color scheme.

Another option would be to add two actions instead, one that switch to previous color scheme and one that switch to next color scheme. Then, I think keyboard shortcuts to these actions could even be added. I think this would allow to address the original issue and @ccordoba12's concerns about not having a "single dark or light color scheme we could go to."

Switch to previous/next color scheme may satisfy the need at some point. But I still a light/dark mode is useful.

For example, someone uses a laptop both at home and office, during daytime and night, maybe with light at the room turned on and off, he/she may often need to switch between dark and light mode.

I don't know others, but if there's no easy way to switch, I may stick to that. If there is, it'll definitely be helpful. Anyway, it's just my own opinion.

Switch to previous/next color scheme may satisfy the need at some point. But I still a light/dark mode is useful.

But, I don't see how this doesn't solve the issue. You would just have to set the dark mode that you want to use, then set the light mode that you want to use in the preference panel once.

After that, you would just have to use the switch to previous function in the menu to go to your "selected" dark mode, then switch to next to go back to your light mode, and you can do that back and forth as much as you want, day and night.

But maybe the first option to add a simple go to last used scheme is better and even easier to understand and would achieve the same results with only one menu function/shortcut....

Distilling the non-repetitive/verbose portions of my comments from the PR thread:

Limitations of the Submenu w/All Schemes and No Shortcuts Approach

  • The user would still have to open the menu, navigate to the submenu, and scroll through the (soon to be much longer, thanks to #8381 ) list of schemes to find the one they want, vs. opening preferences (with a KB shorcut), selecting the desired scheme from the menu, and hitting Enter to confirm. In my testing, both took 5-6 seconds (plus time to apply), the former within a second of the latter
  • This isn't helped by the 10 s (clean prefs) to 20-30 s (heavily customized prefs) delay needed to apply the scheme, so the time saved is inconsequental.
  • If switching between light/dark themes (the primary use case), a restart is required, making it take even longer and be more burdensome

Potential Improvements/Ideas

  • Make the menu only show the last 5 most recently used color schemes, or allow the user to select any number of "favorite" themes to include in the list (or at their option either one)
  • Maybe separate it by light and dark themes, which combined with the previous would make it a little quicker to swap between them (the user could just select their favorite of each)
  • Optimize the color scheme switching routine to not take so long, especially with large prefs files
  • Setting a default dark/light theme in preferences? There would need to be UI for it as it really doesn't fit with the current, and there would still need to be a toolbar icon or menu menu item for each (it could be a toggle, but how to handle a case where you're not using either "default" theme?)

Switch to previous/next color scheme may satisfy the need at some point. But I still a light/dark mode is useful.

But, I don't see how this doesn't solve the issue.

Agreed; I'm not sure I understand how this really helps. Moreover, idea 1 above essentially offers a more flexible version of the basic functionality (pick two themes or any number of themes, in your preferred order, to switch between in the color schemes submenu).

Agreed; I'm not sure I understand how this really helps. Moreover, idea 1 above essentially offers a more flexible version of the basic functionality (pick two themes or any number of themes, in your preferred order, to switch between in the color schemes submenu).

Ok, then what about adding a single action to the Source menu to go back to last used scheme ? The advantage over the list is that we would be able to set a shortcut to this. Also, no submenu needed, so less mouse travelling.

Basically, let's say you start with a light scheme. Then the first time, you would have to go in the preferences to select a dark scheme like you would normally do now. But then, after that, you would be able to use the go back to last used scheme to go back to the light scheme quickly, and use it again to go back to the dark scheme, then again to go back to the light scheme, and so on.

Ok, then what about adding a single option to go back to last used scheme ? The advantage over the list is that we would be able to set a shortcut to this.

Sorry, I must have missed that while I was editing down my comments. That's somewhat less flexible than a recently used list, but having the shortcut is a huge advantage of the "Restore last syntax scheme" approach so long as the desired scheme is the most recent (i.e. the user only has two schemes they commonly switch between, which is probably the majority who fall into this use case to begin with).

To get the advantages of both without too much work, you could make the first/last item in the submenu be "Restore last syntax scheme" with the shortcut, followed by a menu separator and the last 5 schemes in order, or just list the schemes in MRU order as I proposed, but assign to the first one a configurable "Restore last syntax scheme" shortcut.

To get the advantages of both without too much work, you could make the first/last item in the submenu be "Restore last syntax scheme" with the shortcut, followed by a menu separator and the last 5 schemes in order, or just list the schemes in MRU order as I proposed, but assign to the first one a configurable "Restore last syntax scheme" shortcut.

But as you said yourself, adding a list, albeit shorter, doesn't really help to speed up switching between syntax schemes faster. So do we really need to add that flexibility in the menu when that flexibility is already provided in the Preferences?

Touche, good point—agreed. The recently used list would help a small minority of use cases, but as mentioned having the shortcut is the huge advantage of your approach. While it wouldn't cover all use cases, the marginal benefit to the recently used list in those over just opening preferences is rather small. and thus isn't worth implementing unless someone wants to.

Just my 2 cents here but we could add another scheme selection drop down called alternate scheme in preferences below the create new scheme button. We then could activate this alternate scheme in the source menu with a toggle (with a check mark) called Alternate highlighting scheme and a hot key can toggle it between the main and alternate scheme. This gives the users the choice of schemes, doesn't require tracking history and one hot key.

This is a good idea. I support this.

Sure, that's a great idea @bcolsen . If others agree, then I'm on board, with a few refinements:

  • The dropdown should be below the current "Syntax scheme:", not all the way down below "Create new scheme"
  • We should change "Syntax scheme" to "Primary syntax scheme" and call the new one "Alternate syntax scheme"
  • In the menus, we should call it "Alternate syntax highlighting scheme"

The dropdown should be below the current "Syntax scheme:", not all the way down below "Create new scheme"

This of course would be the best place but I think the edit selected, reset and delete structure would have to be changed because it would be ambiguous which we would be editing. They could be renamed but it wouldn't be a simple as it is now. With the option below the buttons very few changes are needed and it's sort of a more advance feature so it's not so bad that's it's out of the way.

That being said I wouldn't be apposed if there was a different/better way to do the theme customization. For example the buttons would be slick as icons(edit(pencil), revert(refresh circle arrow), delete( 'x')) with tool tips next to both the drop downs with create new button down below both dropdown lists, but I think proposing this would be outside the scope here and the implementation(I haven't looked) would be more effort.

The dropdown should be below the current "Syntax scheme:", not all the way down below "Create new scheme"
We should change "Syntax scheme" to "Primary syntax scheme" and call the new one "Alternate syntax scheme"
In the menus, we should call it "Alternate syntax highlighting scheme"

This proposal is way too complex, so I don't agree with it, sorry. It'd be really confusing for people who don't understand what it stands for and it serves a minimal and pretty narrow use case.

During my years as a maintainer I've had to remove a lot of unnecessary configurability created by Pierre, and this looks to go exactly in that same direction.

This proposal is way too complex, so I don't agree with it, sorry.

@ccordoba12 ok, fair enough. If we backtrack a little then, what about adding a simple action to go back to the last used syntax scheme in the Source menu as discussed in https://github.com/spyder-ide/spyder/issues/8317#issuecomment-447204951?

To make an analogy, this feature would act like hitting Ctrl-Tab in the Editor to switch back and forth between 2 files.

Yeah, I see your point @ccordoba12 . It adds an extra layer of complexity on top of just switching between the two most recently used themes, and come to think of it it actually doesn't really add any actual functionality since the user would have to switch the themes back and forth in preferences either way if they wanted to use a third theme, while in the Editor the UX is identical (a hotkey to toggle back and forth). The only benefit would be being able to set the second theme ahead of time, but that's pretty minor.

That said, @jnsebgosselin 's proposal, i.e. a single Toggle last syntax highlighting scheme command in the Source menu with a shortcut, is much simpler while fully addressing the OP's use case (aside from reducing the syntax scheme apply time, which I presume is out of scope here).

If we backtrack a little then, what about adding a simple action to go back to the last used syntax scheme in the Source menu

I agree with this solution. It's simple and very intuitive.

It seems us three agree then.

@abudden @gepcel Does this then address your use case?

@CAM-Gerlach A single Toggle last syntax highlighting scheme command with the ability to assign that to a shortcut key would be perfect for my use case.

@CAM-Gerlach

Does this then address your use case?

Yes. Thanks very much.

Thanks @abudden and @gepcel . Looks like we have consensus then.

@chends888 would you still like to implement this?

@CAM-Gerlach Sorry, I'm busy these days, I'll save this for whenever I'm available. Thanks for the support everyone!!

Was this page helpful?
0 / 5 - 0 ratings