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

[WIP] Switching syntax styles option #184

Closed

Conversation

mariacamilarg
Copy link
Contributor

Now there is an option to change to a different syntax style that opens a new tab in the console with the selected color scheme:

image1

@mariacamilarg
Copy link
Contributor Author

@ccordoba12 @minrk I was doing this PR in order to find out if there was a way of changing the syntax_style without creating a new tab but that instead it got updated automatically in the same shell I've been working on.

The initial intention was inspired by spyder's spyder-ide/spyder#3908. However I was unable to do so. Do any of you know if this is possible? Or do I have to restart it and initialize it with the new config (as in this PR)?

@takluyver
Copy link
Member

JupyterWidget has a _syntax_style_changed() method, which should be called automatically when syntax_style is set. So if you can get the active JupyterWidget instance, you should be able to do:

jupyter_widget.syntax_style = new_style

It might be that that doesn't work, though, if no-one's tested it before.

@@ -730,6 +739,20 @@ def toggleFullScreen(self):
def set_paging_active_frontend(self, paging):
self.active_frontend._set_paging(paging)

def get_available_syntax_styles(self):
Copy link
Member

Choose a reason for hiding this comment

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

We can use a pygments function to find the available styles:
http://pygments.org/docs/styles/#getting-a-list-of-available-styles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this is way better! Thank you!

@wmvanvliet
Copy link
Contributor

awesome!

@mariacamilarg
Copy link
Contributor Author

JupyterWidget has a _syntax_style_changed() method, which should be called automatically when syntax_style is set. So if you can get the active JupyterWidget instance, you should be able to do: jupyter_widget.syntax_style = new_style

@takluyver I tried to do so before in another project (Spyder IDE) where I have the JupyterWidget instance:

image

The interesting thing was that the style_sheet was updated automatically (without restarting it or making a new tab). But the syntax style did not, it only got updated after I restarted Spyder.

This makes me think about your last line and that it maybe doesn't work. I tried to check both functions a bit but I couldn't figure out fast what could be wrong with the _syntax_style_changed() one.

@wmvanvliet
Copy link
Contributor

Since this creates a new kernel, shouldn't this option do in the "Kernel" menu? Is there no way to change the pygments coloring of the currently running kernel? That would be super.

@ccordoba12
Copy link
Collaborator

@wmvanvliet, we'll fix that because we need it for Spyder.

@wmvanvliet wmvanvliet changed the title PR: switching syntax styles option [WIP] Switching syntax styles option Mar 22, 2017
@ccordoba12
Copy link
Collaborator

Closing in favor of #217.

@ccordoba12 ccordoba12 closed this Jun 2, 2017
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.

None yet

4 participants