CadQuery / CQ-editor

CadQuery GUI editor based on PyQT
Apache License 2.0
723 stars 111 forks source link

Dark mode theme #426

Closed yamsu closed 5 months ago

yamsu commented 5 months ago

I'm finding CQ-Editor really useful to learn and use cadquery. However, I couldn't figure out how to get a dark theme set for the entire app and not just the editor widget.

I have a crude work around that involve editing the CQ-editor python files directly

from PyQt5.QtWidgets import QApplication

Add Dark mode

import qdarktheme

NAME = 'CQ-editor'

need to initialize QApp here, otherewise svg icons do not work on windows

app = QApplication(sys.argv, applicationName=NAME)

Add Dark Mode

qdarktheme.setup_theme()

from .main_window import MainWindow

The console doesn't seen to be effected by qdarktheme and requires are minor update, note `%colors Linux` in the console doesn't seem to work either.
- for dark mode in the console 
  edit the following `./cq-editor/lib/python3.11/site-packages/cq_editor/widgets/console.py`
-  Add line preceded by `# Add Dark Mode`
``` python
class ConsoleWidget(RichJupyterWidget,ComponentMixin):

    name = 'Console'

    def __init__(self, customBanner=None, namespace=dict(), *args, **kwargs):
        super(ConsoleWidget, self).__init__(*args, **kwargs)

#        if not customBanner is None:
#            self.banner = customBanner

        # Add Dark Mode
        self.set_default_style(colors='linux')
        self.font_size = 6
        self.kernel_manager = kernel_manager = QtInProcessKernelManager()
jmwright commented 5 months ago

Possibly related: https://github.com/CadQuery/CQ-editor/issues/304

yamsu commented 5 months ago

Possibly related: #304

There is also the fork mentioned in #304 that does this and allows one to choose the theme. Although pyqdarktheme has an option to detect the system colorscheme. But i have not tested this.

qdarktheme.setup_theme('auto')