How to set background color for ParameterTree?

572 views
Skip to first unread message

Eugene E.

unread,
Jul 8, 2018, 1:01:13 PM7/8/18
to pyqtgraph
Hello!

I am placing ParameterTree near the PlotWidget and woul like to apply a dark theme to the tree so it maches the default dark theme for PlotWidget. How do I set backgound and foreground color for ParameterTree instance?

So far I found out about palette but it seems not to work for the items inside a tree:

w = ParameterTree()
pl
= w.palette()
pl
.setColor(w.backgroundRole(), QtGui.QColor('black'))
w
.setPalette(pl)
w
.show()

Any suggestions how to affect the whole tree?

Luke Campagnola

unread,
Jul 10, 2018, 6:47:08 PM7/10/18
to pyqt...@googlegroups.com
I have not tried with ParameterTree specifically, but I would look at Qt's stylesheets:

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/c779cd9f-b379-4ede-96c9-3d2d215396ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eugene E.

unread,
Jul 16, 2018, 3:33:04 PM7/16/18
to pyqtgraph
Thank you very much!

For future reference I used the following code for stylizing ParameterTree:
parameter_tree.setStyleSheet("""
QTreeView {
    background-color: rgb(
46, 52, 54);
    alternate-background-color: rgb(39, 44, 45);    
    color: rgb(238, 238, 238);
}
QLabel {
    color: rgb(238, 238, 238);
}
QTreeView::item:has-children {
    background-color: '#212627';
    color: rgb(233, 185, 110);
}
QTreeView::item:selected {
    background-color: rgb(92, 53, 102);
}
    """
)



On Wednesday, July 11, 2018 at 1:47:08 AM UTC+3, Luke Campagnola wrote:
I have not tried with ParameterTree specifically, but I would look at Qt's stylesheets:
On Sun, Jul 8, 2018 at 10:01 AM, Eugene E. <omeg...@gmail.com> wrote:
Hello!

I am placing ParameterTree near the PlotWidget and woul like to apply a dark theme to the tree so it maches the default dark theme for PlotWidget. How do I set backgound and foreground color for ParameterTree instance?

So far I found out about palette but it seems not to work for the items inside a tree:

w = ParameterTree()
pl
= w.palette()
pl
.setColor(w.backgroundRole(), QtGui.QColor('black'))
w
.setPalette(pl)
w
.show()

Any suggestions how to affect the whole tree?

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.

Al Piszcz

unread,
Jul 16, 2018, 8:52:06 PM7/16/18
to pyqt...@googlegroups.com
Is something else needed?, I am not seeing any change in the parameter tree panel using the example provided.
Thank you.
ptree1 = ParameterTree()
ptree1.setStyleSheet("""
QTreeView {
background-color: rgb(46, 52, 54);
alternate-background-color: rgb(39, 44, 45);
color: rgb(238, 238, 238);
}
QLabel {
color: rgb(238, 238, 238);
}
QTreeView::item:has-children {
background-color: '#212627';
color: rgb(233, 185, 110);
}
QTreeView::item:selected {
background-color: rgb(92, 53, 102);
}
""")
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/7b5f1b3c-6c31-4c92-9c5b-aa277a096e0e%40googlegroups.com.

Eugene E.

unread,
Jul 17, 2018, 5:11:33 AM7/17/18
to pyqtgraph
That is all for me. In the example you provided you must instantly see the change in backgorund color. May that be that you already have dart qt theme and there are just no visible changes? Try changing backgound color to yellow perhaps...

For now I use pyqtgraph from jupyter and from within jupyter's notebook MWE for this case is:
%gui qt5

from pyqtgraph.parametertree import (Parameter, ParameterTree)

parameters
= [
       
{'name': 'signal',
         
'type': 'group',
         
'children': [ {'name': 'n', 'type': 'int', 'value': 0, 'readonly': True},
                       
{'name': 'fc', 'type': 'float', 'value': 1, 'siPrefix': True, 'suffix': 'Hz', 'readonly': True},
                       
{'name': 'ts', 'type': 'float', 'value': 2, 'siPrefix': True, 'suffix': 's', 'readonly': True}]
       
},
   
]

root_parameter
= Parameter.create(name='params', type='group', children=parameters)


ptree1
= ParameterTree()
ptree1
.setStyleSheet("""
QTreeView {
    background-color: rgb(46, 52, 54);
    alternate-background-color: rgb(39, 44, 45);    
    color: rgb(238, 238, 238);
}
QLabel {
    color: rgb(238, 238, 238);
}
QTreeView::item:has-children {
    background-color: '#212627';
    color: rgb(233, 185, 110);
}
QTreeView::item:selected {
    background-color: rgb(92, 53, 102);
}
    """
)

ptree1
.setParameters(root_parameter, showTop=False)
ptree1
.show()


Al Piszcz

unread,
Jul 17, 2018, 3:08:11 PM7/17/18
to pyqt...@googlegroups.com
thank you, your example is fine. ideally the title bar color could change, guessing that is beyond the scope.


To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/8f61c4bf-f50f-4ec3-891a-abb01e77a704%40googlegroups.com.

Eugene E.

unread,
Jul 17, 2018, 4:18:28 PM7/17/18
to pyqtgraph
You can google much stylesheet example knowing that behind the scene ParameterTree is QTreeview, so much of the style are valid as well. For the rest you can see the source of the ParameterTree for example to see that values while non-editable are in fact QLabels, etc.

For my project I disable the header at all since Property-Value meaning of the tree in my opinion is self-evident.

Al Piszcz

unread,
Jul 18, 2018, 7:30:22 PM7/18/18
to pyqt...@googlegroups.com
Concur what is the command to disable the header? tx.

To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/1c64c4c0-46de-4b7a-b419-efbbd4e9b03a%40googlegroups.com.

Al Piszcz

unread,
Jul 20, 2018, 8:27:09 AM7/20/18
to pyqtgraph
1. Any pointers on how disable the Parameter, Value header appreciated.
2. The colors scheme earlier in this thread causes the collapse expand icons to become nearly invisible, can those be set to a brighter color to stand out against the dark background?

Eugene E.

unread,
Jul 23, 2018, 3:54:18 AM7/23/18
to pyqtgraph
class pyqtgraph.parametertree.ParameterTree(parent=None, showHeader=True)

Al Piszcz

unread,
Jul 23, 2018, 1:51:42 PM7/23/18
to pyqt...@googlegroups.com
Thank you.

To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/8c936b38-08b0-4777-98b6-894bb22f642b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages