Unable to change the background color of DockLabel
-
Hello, i tried to change the background color of DockLabel (class from anaconda package) using
self.ImageDock.label.setStyleSheet("background-color: #04B2E2; color: white;")
the default color is purple : #66c and i wanna change it to blue #04B2E2
BUT IT DIDNT WORK!
changing it from the actual package works but i dont wanna modify the class directly.
Any idea how can i do that dynamically?? thanks! -
Hi and welcome to devnet,
Where does that class come from ?
Which Python bindings are you using ?
Can you provide a minimal runnable script that shows this issue ? -
sure!
[link text](from PyQt5.QtWidgets import QApplication, QMainWindow
from pyqtgraph.dockarea import Dock, DockArea
import pyqtgraph as pg
import sysclass DockApp(QMainWindow):
def init(self):
super().init()
self.setWindowTitle("Dockable Display App")
self.setGeometry(100, 100, 800, 600)self.area = DockArea() self.setCentralWidget(self.area) self.set_dock_default() def set_dock_default(self): """Sets up the dock with a display window.""" self.image_dock = Dock(name="Display Dock", size=(1, 1)) self.image_dock.label.setStyleSheet("background-color: #04B2E2;") #change to blu but doesn't work self.display_window = pg.PlotWidget(title="Image Display") self.display_window.getViewBox().invertY(True) # Inverting Y axis self.image_dock.addWidget(self.display_window) self.area.addDock(self.image_dock, "top")
if name == "main":
app = QApplication(sys.argv)
window = DockApp()
window.show()
sys.exit(app.exec_())
) -
sorry i messed up the code in the first reply, i'm new here haha
from PyQt5.QtWidgets import QApplication, QMainWindow from pyqtgraph.dockarea import Dock, DockArea import pyqtgraph as pg import sys class DockApp(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Dockable Display App") self.setGeometry(100, 100, 800, 600) self.area = DockArea() self.setCentralWidget(self.area) self.set_dock_default() def set_dock_default(self): """Sets up the dock with a display window.""" self.image_dock = Dock(name="Display Dock", size=(1, 1)) self.image_dock.label.setStyleSheet("background-color: #04B2E2;") #change to blu but doesn't work self.display_window = pg.PlotWidget(title="Image Display") self.display_window.getViewBox().invertY(True) # Inverting Y axis self.image_dock.addWidget(self.display_window) self.area.addDock(self.image_dock, "top") if __name__ == "__main__": app = QApplication(sys.argv) window = DockApp() window.show() sys.exit(app.exec_())