mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.41k stars 435 forks source link

True dark mode #970

Open bythckr opened 4 years ago

bythckr commented 4 years ago

This is a suggestion. First off, love the project and a nice tool to learn python. Much better than IDLE. Hope its become standard in python soon.

In the dark mode/theme,

dybber commented 4 years ago

Just checked what the status is now.

devdanzin commented 3 years ago

Making the Python 3 REPL follow the theme seems to be a simple enough change. It seems we could even use the current theme CSS files if we want matching colors.

For the REPL, High contrast is trivial, it's white on black and only the prompt color can be argued. Night theme can be turned into a fully-colorful dark theme (using monokai below), or kept much closer to its current black-on-white styling (but dark).

Here's a quick demo from the minimal changes below:

https://user-images.githubusercontent.com/74280297/104253619-b9228c80-5453-11eb-9dce-6b208fe44571.mp4

The Night->Day colors aren't working well, but from High Contrast and Day flipping black/white, it seems to be simply a matter of redefining those colors in the right places.

diff --git a/mu/interface/panes.py b/mu/interface/panes.py
index c1deb6e..e7f31dc 100644
--- a/mu/interface/panes.py
+++ b/mu/interface/panes.py
@@ -56,6 +56,8 @@ from PyQt5.QtGui import (
     QStandardItem,
 )
 from qtconsole.rich_jupyter_widget import RichJupyterWidget
+from qtconsole import styles
+from pygments.styles.bw import BlackWhiteStyle
 from ..i18n import language_code
 from mu.interface.themes import Font
 from mu.interface.themes import DEFAULT_FONT_SIZE
@@ -84,6 +86,11 @@ PANE_ZOOM_SIZES = {
 }

+class HighContrastStyle(BlackWhiteStyle):
+    color = "#ffffff"
+    background_color = "#000000"
+
+
 class JupyterREPLPane(RichJupyterWidget):
     """
     REPL = Read, Evaluate, Print, Loop.
@@ -124,9 +131,10 @@ class JupyterREPLPane(RichJupyterWidget):
         Sets the theme / look for the REPL pane.
         """
         if theme == "contrast":
-            self.set_default_style(colors="nocolor")
+            self.style_sheet = styles.default_dark_style_sheet
+            self._highlighter.set_style(HighContrastStyle)
         elif theme == "night":
-            self.set_default_style(colors="nocolor")
+            self.set_default_style(colors="linux")
         else:
             self.set_default_style()
devdanzin commented 3 years ago

Regarding dark buttons, we can easily update the ButtonBar icons on theme change. Maybe having one set for dark themes and one for the Day theme. We could either adapt each PNG image or programmatically transform them in Qt (doesn't seem worth the trouble).

Here's something close to the visual effect I think we'd want, but not good enough (the trick is transparent icons, so they don't look good in Day theme because they don't have a white background anymore). Let's pretend the zoom buttons were left unchanged on purpose to... er... allow comparison to current look?

https://user-images.githubusercontent.com/74280297/104256335-cc385b00-5459-11eb-89ac-d43d184d818f.mp4

Happy to implement any ideas or suggestions for testing.

dybber commented 3 years ago

@ntoll or @ZanderBrown: Do we have vector versions of the buttons?

ntoll commented 3 years ago

Yes... sort of. I created / found / reused some for my Mu-tate experiment here: https://github.com/mu-editor/Mu-tate/tree/master/mu/icons

ntoll commented 3 years ago

NB, not all the icons are the same as our current ones, but they're close enough.