mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
feat(toolbar):colors adjusted
This commit is contained in:
@ -50,19 +50,19 @@ class ModularToolBar(QToolBar):
|
||||
"""Modular toolbar with optional automatic initialization.
|
||||
Args:
|
||||
parent (QWidget, optional): The parent widget of the toolbar. Defaults to None.
|
||||
auto_init (bool, optional): If True, automatically populates the toolbar based on the parent widget.
|
||||
actions (list[ToolBarAction], optional): A list of action creators to populate the toolbar. Defaults to None.
|
||||
target_widget (QWidget, optional): The widget that the actions will target. Defaults to None.
|
||||
color (str, optional): The background color of the toolbar. Defaults to "black".
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, actions=None, target_widget=None):
|
||||
def __init__(self, parent=None, actions=None, target_widget=None, color: str = "black"):
|
||||
super().__init__(parent)
|
||||
|
||||
self.setStyleSheet("QToolBar { background: transparent; }")
|
||||
self.setIconSize(QSize(20, 20))
|
||||
self.widgets = defaultdict(dict)
|
||||
self.set_background_color(color)
|
||||
|
||||
if actions is not None and target_widget is not None:
|
||||
self.populate_toolbar(actions, target_widget)
|
||||
# QTimer.singleShot(0, lambda :self.set_manual_actions(actions, target_widget))
|
||||
|
||||
def populate_toolbar(self, actions: dict, target_widget):
|
||||
"""Populates the toolbar with a set of actions.
|
||||
@ -75,3 +75,10 @@ class ModularToolBar(QToolBar):
|
||||
for action_id, action in actions.items():
|
||||
action.add_to_toolbar(self, target_widget)
|
||||
self.widgets[action_id] = action
|
||||
|
||||
def set_background_color(self, color: str):
|
||||
self.setStyleSheet(f"QToolBar {{ background: {color}; }}")
|
||||
self.setIconSize(QSize(20, 20))
|
||||
self.setMovable(False)
|
||||
self.setFloatable(False)
|
||||
self.setContentsMargins(0, 0, 0, 0)
|
||||
|
Reference in New Issue
Block a user