Exemplo n.º 1
0
def styleApp():
    uiDefaults = UIManager.getDefaults()
    e = uiDefaults.keys()
    while e.hasMoreElements():
       obj = e.nextElement()
       if type(obj) == types.StringType:
           if obj.endswith("background") and \
              isinstance(uiDefaults.get(obj), Color):
               if str(obj).startswith('List.'):
                   uiDefaults.put(obj, Color(240, 240, 240))
               else:
                   uiDefaults.put(obj, Color.WHITE)
Exemplo n.º 2
0
    def setTheme(self, themeName):
        """
        Updates all the existing styles, and recolors the command window
        to match the new styles if any text is present.
        """
        # Pick our fonts!
        self.defaultFontFamily = \
            UIManager.getDefaults().getFont("EditorPane.font").getFamily()
        self.monoFontFamily = 'Monospaced'

        # Check that the theme exists
        if themeName not in THEMES:
            themeName = DEFAULT_THEME_NAME

        self.themeName = themeName
        self.theme = theme = THEMES[themeName]

        # Set the default style
        baseStyle = self.getStyle('default')
        StyleConstants.setBackground(baseStyle, theme.backgroundColor)
        self._setStyle(baseStyle, theme.defaultStyle)

        # Set the pretty text styles
        existingStyles = set(self.getStyleNames())
        for name in ALL_STYLES:
            if name in existingStyles:
                style = self.getStyle(name)
            else:
                style = self.addStyle(name, baseStyle)

            styleSpec = theme.styles.get(name, (None, None))
            styleSpec = (
                (theme.defaultStyle[0] if styleSpec[0] is None else styleSpec[0]),
                (theme.defaultStyle[1] if styleSpec[1] is None else styleSpec[1])
            )
            self._setStyle(style, styleSpec)

        self._recolorDocument()
        self.onThemeSet.send(self)
Exemplo n.º 3
0
    def setTheme(self, themeName):
        """
        Updates all the existing styles, and recolors the command window
        to match the new styles if any text is present.
        """
        # Pick our fonts!
        self.defaultFontFamily = \
            UIManager.getDefaults().getFont("EditorPane.font").getFamily()
        self.monoFontFamily = 'Monospaced'

        # Check that the theme exists
        if themeName not in THEMES:
            themeName = DEFAULT_THEME_NAME

        self.themeName = themeName
        self.theme = theme = THEMES[themeName]

        # Set the default style
        baseStyle = self.getStyle('default')
        StyleConstants.setBackground(baseStyle, theme.backgroundColor)
        self._setStyle(baseStyle, theme.defaultStyle)

        # Set the pretty text styles
        existingStyles = set(self.getStyleNames())
        for name in ALL_STYLES:
            if name in existingStyles:
                style = self.getStyle(name)
            else:
                style = self.addStyle(name, baseStyle)

            styleSpec = theme.styles.get(name, (None, None))
            styleSpec = ((theme.defaultStyle[0]
                          if styleSpec[0] is None else styleSpec[0]),
                         (theme.defaultStyle[1]
                          if styleSpec[1] is None else styleSpec[1]))
            self._setStyle(style, styleSpec)

        self._recolorDocument()
        self.onThemeSet.send(self)