Skip to content

Commit

Permalink
hide widget
Browse files Browse the repository at this point in the history
  • Loading branch information
PingHsunTsai committed Jun 18, 2024
1 parent e68f278 commit 053480c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/compas_viewer/components/objectsetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,9 @@ def update(self):
text = "Update Object"
obj_setting_layout, self.spin_boxes = output
self.layout.addLayout(obj_setting_layout)
else:
text = "No object selected."

self.update_button = QPushButton(text, self)
self.update_button.clicked.connect(self.obj_update)
self.layout.addWidget(self.update_button)
self.update_button = QPushButton(text, self)
self.update_button.clicked.connect(self.obj_update)
self.layout.addWidget(self.update_button)

def obj_update(self):
"""Apply the settings from spin boxes to the selected objects."""
Expand Down
11 changes: 11 additions & 0 deletions src/compas_viewer/ui/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
from PySide6 import QtCore
from PySide6 import QtWidgets

from compas_viewer.components.objectsetting import ObjectSetting

if TYPE_CHECKING:
from .ui import UI


def is_layout_empty(layout):
return layout.count() == 0


class SideBarRight:
def __init__(self, ui: "UI", show: bool = True) -> None:
self.ui = ui
Expand All @@ -18,6 +24,11 @@ def update(self):
self.widget.update()
for widget in self.widget.children():
widget.update()
if isinstance(widget, ObjectSetting):
if is_layout_empty(widget.layout):
widget.hide()
else:
widget.show()

@property
def show(self):
Expand Down

0 comments on commit 053480c

Please sign in to comment.