how to 'dim' certain python statements in PyCharm - python

PyCharm version: Community Edition 4.0.4
Is it possible to customize my color scheme for a python file in PyCharm such that certain statements are of darker color?
e.g. I want to make all statements starting with "logger" to be of gray color so that I can focus on my main code without having to wade through lot of info/debug statements.
I tried to find out if I can add new keyword in keywords1 keywords2 keywords3 keywords4 but can't find any such option. And on top of that, I can't find any way to alter colors for keyword1/2/3/4 individually.
I can't be the only one wanting to hide/dim logging statements!

There is no such feature in PyCharm 4.

Related

Python syntax highlighting using PyChar and IDLE

I have a text editor I'm working on. Using PyCharm. I have line number support (many thanks to Bryan Oakley!) and python syntax highlighting using IDLE Perculator. It works but some of the highlight code is hard to read. Oh yes, using tkinter for GUI support.
Can anyone point me at how to set the colors in IDLE? I use options-configure IDLE and some of the changes work in my project and some don't. For example, disabling the colors in my find funcion in the editor doesn't use the 'found' attribute when I alter the 'found' highlight colors. It only highlights what is found when I set the foreground and background colors.
I would prefer to edit a file so I know what it is highlighting, such as comments, strings, keywords, etc.
The IDLE Perculator works better than all of the highlight code I tested.
Just been trying to work out how to set the highlight colors to what I want. Either light or dark themes.
Found basic doc. for IDLE but nothing on how to figure out what is what. Only some settings take effect.
I found all of the idlelib source in the appdata folders and put it into my project folder. I know can set the backgrounds in the IDLE shell for the various keywords etc. Looks ok for a dark theme now. When I run or compile I get the colors I set in the IDE in my text (editor) widget. I still have to set the default text colors in my app. When I don't, I get black text on white background which looks terrible in the dark theme.
So a little more work...

Get color scheme from GTK

I am developing a desktop app using Python 3 and GTK3.
I need a button to change its background color when hover, which can be done with this:
self.uploadbutton.modify_bg(Gtk.StateType.PRELIGHT, self.color)
Until now, I defined a RGB color that matches my own theme, but as I have to release this code, I would like to change that color to one of the established theme colors.
Searching the web, I found there's a way to do it with GTK2, but since version 3.8 of GTK, the gtk-color-scheme property has been deprecated.
Is there any other way to respect the user theme colors without using this property?
For now I have found two ways. Both of them are not the answer to your question, because as far as I understand in GTK3 every single element can have it's own styling (including color).
The first one is official and says not to mess with themes unless you have tested them and know how exactly your modifications would look. I think it's the best solution since it's not clear at compile-time whether your self.color will make it look ok or totally unreadable.
The second solution is to obtain full CSS and parse it yourself.
gset = Gtk.Settings.get_default ()
themename = gset.get_property ("gtk-theme-name")
prefdark = gset.get_property ("gtk-application-prefer-dark-theme") # it's a boolean
cprov = Gtk.CssProvider.get_named (themename)
print (cprov.to_string())
Parsing the theme is outside of this question.

Change Spyder's error colors

I would like to change the Error colors in the IPython console in Spyder. Is that possible? I use Spyder 3.6 (if it matters). The error message is a mix of green and yellow... I have no know issues with my vision and I find it quite hard to read.
Here is an example:
According to this, the colors in iPython console are hardcoded and cannot be changed by Spyder itself.
One suggestion would be to switch to a dark background, so that colors like yellow are much easier to read. To do that, you can go to: Tools -> Preferences -> IPython console -> Display and click on Dark background.
Another alternative could be to use IPython %color magic to modify color scheme: https://ipython.org/ipython-doc/3/config/details.html#terminal-colors
Unfortunately, according to this, it seems as if the colour scheme cannot be changed at this moment in time.
Hopefully, the feature will be supported in future. You could try looking into a different IDE that might suit your needs.

spyder IDE sidebar, rename, find all occurances?

I have some questions about spyder 3.2.4 ide for python:
The "sidebar" (to the right of the main code-window) which marks all lines with warnings, all lines with todo etc with a small colored marker. Can I set these colors? Can I disable which ones to show?
Can I "smart rename" a variable like in other IDEs? I mean not just text replace, but actually make sure i just rename the selected variable (all occurances and nothing but it) and not just text matching a string i type in like i would in "word".
Can I list all occurances of a variable like in other IDEs? Lets say I have a list called "combinedAreas" and want to list all the uses of that variable, preferably also being ablo to click a line and jump to that line.
Thanks!
(Spyder maintainer here) About your questions:
Can I set these colors?
No
Can I disable which ones to show?
Yes, you can do that by going to
Preferences > Editor > Code Introspection/Analysis > Analysis
Can I "smart rename" a variable like in other IDEs?
Not right now, but we're trying to implement this feature for Spyder 4 (our next major release).
Can I list all occurances of a variable like in other IDEs?
No, but it's also planned for Spyder 4.

Highlighting comments in Python script

I am using Pycharm. I often use # TODO, which highlights the comment in blue. Is it possible to highlight other comments in a different colour, using other keywords?
For example, I would like to be able to highlight important notes in red, say using # NOTE.
To add a custom highlight for comments in Python scripts, go to File -> Settings -> Editor -> TODO and add a new pattern:
Configure, as needed:
Bright Red is hard to miss:
PyCharm HELP

Categories