How to change the background color of a DockLabel instance??
-
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??
Here's a minimal runnable script that shows this issuefrom 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 blue but doesn't work, it still shows as purple 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_())
-
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??
Here's a minimal runnable script that shows this issuefrom 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 blue but doesn't work, it still shows as purple 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_())
@bea1999 said in How to change the background color of a DockLabel instance??:
changing it from the actual package works but i dont wanna modify the class directly.
What do you mean by this? If, say, you are inside
Dock
's class code and you can goself.label.setStyleSheet(...)
and that works then I cannot see whyself.image_dock.label.setStyleSheet(...)
from the outside world would not work. Are you sure you are supposed to set itslabel
, I don't even see the docs explain what that is from https://pyqtgraph.readthedocs.io/en/latest/api_reference/dockarea.html#pyqtgraph.dockarea.Dock. -
@bea1999 said in How to change the background color of a DockLabel instance??:
changing it from the actual package works but i dont wanna modify the class directly.
What do you mean by this? If, say, you are inside
Dock
's class code and you can goself.label.setStyleSheet(...)
and that works then I cannot see whyself.image_dock.label.setStyleSheet(...)
from the outside world would not work. Are you sure you are supposed to set itslabel
, I don't even see the docs explain what that is from https://pyqtgraph.readthedocs.io/en/latest/api_reference/dockarea.html#pyqtgraph.dockarea.Dock.