Toggling dark/light GUI mode / changing matplotlib style
Matthias Brennwald <[email protected]> Fri, 04 Mar 2022 23:02:48 +0100
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <[email protected]> |
--=-an5zVGr1V58A0siQPiCZ Content-Type: text/plain; charset="UTF-8"; format=flowed Hello I am working on a program that uses a wx panel with a matplotlib figure. If the user toggles the GUI environment from light to dark mode (or vice versa), the GUI elements provided by wx will follow the change nicely, but the matplotlib figure will not. I am using the 'default' plot styles for matplotlib when my program detects the "light" GUI setting during startup, while the 'dark_background' style is used if the "dark" setting is detected at startup (like this: <https://matplotlib.org/3.1.0/gallery/style_sheets/dark_background.html> ). While setting the correct matplotlib style works fine at startup, things get more difficult if I am trying to change the style after the user toggles the "light" / "dark" mode. I worked out how the the change can be detected in a handler for the wx.EVT_PAINT event. However, once the GUI style change is detected, matplotlib does not seem to allow applying a different matplotlib style to the existing plot panel. It looks like the whole matplotlib figure would need to be re-created from scratch in order to apply the correct plot style. However, this is not (easily) possible in my application. I'd appreciate any pointers or suggestions on how to deal with "light" / "dark" mode changes in wx/matplotlib panels. Matthias -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/OKQ88R.NFAW8S5P52GH%40gmail.com. --=-an5zVGr1V58A0siQPiCZ Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div id=3D"geary-body" dir=3D"auto"><div>Hello</div><div><br></div><div>I a= m working on a program that uses a wx panel with a matplotlib figure. If th= e user toggles the GUI environment from light to dark mode (or vice versa),= the GUI elements provided by wx will follow the change nicely, but the mat= plotlib figure will not. I am using the 'default' plot styles for matplotli= b when my program detects the "light" GUI setting during startup, while the= 'dark_background' style is used if the "dark" setting is detected at start= up (like this: <a href=3D"https://matplotlib.org/3.1.0/gallery/style_s= heets/dark_background.html">https://matplotlib.org/3.1.0/gallery/style_shee= ts/dark_background.html</a> ).</div><div><br></div><div>While setting the c= orrect matplotlib style works fine at startup, things get more difficult if= I am trying to change the style after the user toggles the "light" / "dark= " mode. I worked out how the the change can be detected in a handler for th= e wx.EVT_PAINT event. However, once the GUI style change is detected, matpl= otlib does not seem to allow applying a different matplotlib style to the e= xisting plot panel. It looks like the whole matplotlib figure would need to= be re-created from scratch in order to apply the correct plot style. Howev= er, this is not (easily) possible in my application.</div><div><br></div><d= iv>I'd appreciate any pointers or suggestions on how to deal with "light" /= "dark" mode changes in wx/matplotlib panels.</div><div><br></div><div>Matt= hias</div></div> <p></p> -- <br /> You received this message because you are subscribed to the Google Groups &= quot;wxPython-users" group.<br /> To unsubscribe from this group and stop receiving emails from it, send an e= mail to <a href=3D"mailto:[email protected]">wxpy= [email protected]</a>.<br /> To view this discussion on the web visit <a href=3D"https://groups.google.c= om/d/msgid/wxpython-users/OKQ88R.NFAW8S5P52GH%40gmail.com?utm_medium=3Demai= l&utm_source=3Dfooter">https://groups.google.com/d/msgid/wxpython-users/OKQ= 88R.NFAW8S5P52GH%40gmail.com</a>.<br /> --=-an5zVGr1V58A0siQPiCZ--