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

Plugins: Background and text color for widgets in line with style in the editor. #594

Open
kelsa-pi opened this issue Mar 14, 2019 · 4 comments

Comments

@kelsa-pi
Copy link
Contributor

Hi,
There is no common method to set background and text color for widget in plugins in line with style in the editor.
Best,

PS:
Using setWidgetStyleSheet(widget) function it is possible to set background and text color for
particular widget in plugin.

Screenshot_2019-03-14_22-49-29

def setWidgetStyleSheet(self, widget):
    # Style
    theme = pyzo.themes[pyzo.config.settings.theme.lower()]['data']
    background_style = theme['editor.text'].split(',')
    background = background_style[1].split(':')[1]
    textcolor_style = theme['syntax.identifier'].split(',')
    textcolor = textcolor_style[0].split(':')[1]
    wdg = str(type(widget))
    wdg = wdg.replace("<class 'PyQt5.QtWidgets.", "").replace("'>", "")
    ss = wdg + '{background-color:%s; color:%s;}' %  (background, textcolor)
    widget.setStyleSheet(ss)
    widget.setAutoFillBackground(True)
@almarklein
Copy link
Member

almarklein commented Mar 15, 2019

I agree that it would be good to have a way of styling the whole IDE along with the syntax style. One way to do this is:

pyzo.main.setStyleSheet("QWidget {background: #000; color:#fff;}")

There are two concerns:

  • This may brake Qt trying to conform to the style of the OS in some cases.
  • Some elements in Pyzo are currently colored in a way that assumes a light background, and some elements (e.g. the logger shell) even apply their own bg color.

I still think we can and should do this, but we should think careful about the user API and adjust the code in a few places to better adopt to varying styles.

@kelsa-pi
Copy link
Contributor Author

Hi,
IMHO we have three option:

  1. Plugin developer create his own fuction to set background and text color in line with style in the editor for particular widget in plugin (eg. setBGandTextColor(self, mywidget)

  2. Plugin developer use helper function eg. pyzo.tools.setBGandTextColor(self, mywidget) to set background and text color in line with style in the editor for particular widget if/when needed in plugin. (eg. Source structure tree is not style friendly).

  3. IDE provide a way of styling the whole IDE along with the syntax style eg. pyzo.main.setStyleSheet("QWidget {background: #000; color:#fff;}")

I'm for option 2.
Option 1 is long shot for styling the IDE, option 3 is hard to implement.
Best

@almarklein
Copy link
Member

Option 3 might be harder, but would be favorable, I think. It's nice if some tools have a good background, but if the main IDE does not, it still looks bad. I think that Pyzo should be responsible for setting the global style, and plugin developers may need to make sure that things look good on dark as well as light backgrounds.

@kelsa-pi
Copy link
Contributor Author

kelsa-pi commented Mar 17, 2019

Option 3 might be harder, but would be favorable,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants