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

windows10/11 Dark Mode Support #2413

Open
MesterPerfect opened this issue Jun 9, 2023 · 6 comments
Open

windows10/11 Dark Mode Support #2413

MesterPerfect opened this issue Jun 9, 2023 · 6 comments

Comments

@MesterPerfect
Copy link

Operating system:
windows 10

wxPython version & source:
wxpython=4.11 pypi

Python version & source:
python3.9.9

Description of the problem:
I can't use dark mode on Windows

Code Example (click to expand)
import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super(MyFrame, self).__init__(parent, title=title, size=(400, 300))
        self.panel = wx.Panel(self)

        # Set dark theme colors
        dark_bg_color = "#252525"  # Dark background color
        dark_fg_color = "#FFFFFF"  # Dark foreground color

        # Set dark theme for the frame and panel
        self.SetBackgroundColour(dark_bg_color)
        self.panel.SetBackgroundColour(dark_bg_color)
        
        # Creating a read-only multi-line edit box
        self.text_ctrl = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY)
        
        # Creating buttons
        self.button1 = wx.Button(self.panel, label='Button 1')
        self.button2 = wx.Button(self.panel, label='Button 2')
        self.button3 = wx.Button(self.panel, label='Button 3')
        self.button4 = wx.Button(self.panel, label='Button 4')
        
        # Creating an edit box for path and browse button
        self.path_text_ctrl = wx.TextCtrl(self.panel)
        self.browse_button = wx.Button(self.panel, label='Browse')
        
        # Setting up the layout using a sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.text_ctrl, proportion=1, flag=wx.EXPAND | wx.ALL, border=10)
        
        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.Add(self.button1, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        button_sizer.Add(self.button2, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        button_sizer.Add(self.button3, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        button_sizer.Add(self.button4, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        
        path_sizer = wx.BoxSizer(wx.HORIZONTAL)
        path_sizer.Add(self.path_text_ctrl, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        path_sizer.Add(self.browse_button, flag=wx.ALL, border=5)
        
        sizer.Add(button_sizer, flag=wx.EXPAND)
        sizer.Add(path_sizer, flag=wx.EXPAND | wx.ALL, border=10)
        
        self.panel.SetSizer(sizer)
        
        # Binding events
        self.browse_button.Bind(wx.EVT_BUTTON, self.on_browse)
        
    def on_browse(self, event):
        dialog = wx.FileDialog(self, "Choose a file", style=wx.FD_OPEN)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
            self.path_text_ctrl.SetValue(path)
        dialog.Destroy()

if __name__ == '__main__':
    app = wx.App()
    frame = MyFrame(None, "Window with wxPython")
    frame.Show()
    app.MainLoop()
@MesterPerfect
Copy link
Author

This is the result I get when I try to apply a dark theme to my program

darkMode

@tatarize
Copy link

More annoying my app MeerK40t (https://github.com/meerk40t/meerk40t) literally does support darkmode for linux and osx but the windows version is a flashlight in your eyes.

You could do this, but you'd basically need to force change all the colors on every widget you use, or build a dark-mode capable set of them

https://www.blog.pythonlibrary.org/2011/11/05/wxpython-creating-a-dark-mode/

@nai-kon
Copy link

nai-kon commented Sep 24, 2023

I found the original wxWidgets experimentally supports dark mode with MSWEnableDarkMode() on ver3.3 (not released yet).
https://docs.wxwidgets.org/latest/classwx_app.html#af8c93d7e3345e62a58325f3ab1d158d6

Are there any plans to support dark mode on wxpython?

@sveinse
Copy link

sveinse commented Apr 9, 2024

Ping. Any plans on getting dark mode support on wxPython for Windows? The users is asking for it. Just implementing the undocumented MSWEnableDarkMode() is worth a shot.

@nai-kon
Copy link

nai-kon commented Sep 12, 2024

Ping. I hope dark mode will be added in the next release.

@swt2c
Copy link
Collaborator

swt2c commented Sep 12, 2024

It will probably be a while before this will be supported in wxPython. I don't have any plans to move to the unstable branch of wxWidgets (3.3). Perhaps you could look into asking if the MSWEnableDarkMode patches could be backported to 3.2.

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

No branches or pull requests

5 participants