[solved] how can I get the font color and background of the FC used theme

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

[solved] how can I get the font color and background of the FC used theme

Post by easyw-fc »

I would need to get in python the font color and background color used by the FC theme...
how can I get i.e. the font color and background of the FC main window?
or better how can I get the theme font and background color attributes?
Last edited by easyw-fc on Wed Feb 08, 2023 3:44 pm, edited 1 time in total.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how can I get the font color and background of the FC used theme

Post by openBrain »

Code: Select all

from PySide2 import QtGui
QtGui.QGuiApplication.palette().text().color()
QtGui.QGuiApplication.palette().background().color()
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Re: how can I get the font color and background of the FC used theme

Post by easyw-fc »

@openBrain
thanks for the code, but it seems it doesn't change changing the FC theme...
I cannot detect the font and background FC theme data...

with no theme:

Code: Select all

from PySide2 import QtGui
QtGui.QGuiApplication.palette().text().color()
PySide2.QtGui.QColor.fromRgbF(0.000000, 0.000000, 0.000000, 1.000000)
QtGui.QGuiApplication.palette().background().color()
PySide2.QtGui.QColor.fromRgbF(0.941176, 0.941176, 0.941176, 1.000000)
with i.e. ProDark theme:

Code: Select all

QtGui.QGuiApplication.palette().text().color()
PySide2.QtGui.QColor.fromRgbF(0.000000, 0.000000, 0.000000, 1.000000)
QtGui.QGuiApplication.palette().background().color()
PySide2.QtGui.QColor.fromRgbF(0.941176, 0.941176, 0.941176, 1.000000)
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how can I get the font color and background of the FC used theme

Post by openBrain »

easyw-fc wrote: Wed Feb 08, 2023 2:26 pm @openBrain
thanks for the code, but it seems it doesn't change changing the FC theme...
I cannot detect the font and background FC theme data...
Maybe theme only change at main window level. Could you try ?

Code: Select all

Gui.getMainWindow().palette().text().color()
Gui.getMainWindow().palette().background().color()
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Re: how can I get the font color and background of the FC used theme

Post by easyw-fc »

thanks a lot! that was the way :D
Post Reply