Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow widgets to be removed from SNUB plot #25

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added snub/gui/icons/x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions snub/gui/stacks/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def __init__(self, config, selected_intervals):
panel = ROIPanel(config, **props)
self.widgets.append(panel)

for w in self.widgets:
w.closed.connect(self.widget_closed)

self.initUI()

def initUI(self):
Expand Down Expand Up @@ -60,3 +63,7 @@ def change_layout_mode(self, layout_mode):
{"columns": Qt.Vertical, "rows": Qt.Horizontal}[layout_mode]
)
super().change_layout_mode(layout_mode)

def widget_closed(self):
if not any([w.isVisible() for w in self.widgets]):
self.hide()
1 change: 0 additions & 1 deletion snub/gui/stacks/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def update_current_range(self, new_range=None):
child.update_current_range(self.current_range)

def update_current_time(self, t):
pass
for w in self.widgets + self.overlays:
w.update_current_time(t)
self.current_time_marker.set_timepoint(t)
Expand Down
18 changes: 18 additions & 0 deletions snub/gui/utils/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def accept_range(self):


class HeaderMixin:
closed = pyqtSignal()

def initUI(
self,
name="",
Expand All @@ -59,6 +61,8 @@ def initUI(
self.header_height = header_height
self.toggle_button = QPushButton()
self.toggle_button.clicked.connect(self.toggle_visiblity)
self.close_button = QPushButton()
self.close_button.clicked.connect(self.hide_widget)

self.title = VerticalLabel(name, orientation="horizontal")
self.header = QWidget(objectName="trackGroup_header")
Expand All @@ -67,6 +71,7 @@ def initUI(
self.header_layout.addWidget(self.title)
self.header_layout.addStretch(0)
self.header_layout.addWidget(self.toggle_button)
self.header_layout.addWidget(self.close_button)
self.layout = QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
Expand All @@ -86,8 +91,17 @@ def initUI(
)
)
)
self.x_icon = QIcon(
QPixmap(
os.path.join(
os.path.dirname(os.path.realpath(__file__)), "../icons", "x.png"
)
)
)
self.toggle_button.setIcon(self.plus_icon)
self.toggle_button.setIconSize(QSize(12, 12))
self.close_button.setIcon(self.x_icon)
self.close_button.setIconSize(QSize(12, 12))

self.setStyleSheet(
"QWidget#trackGroup_header { background-color: rgb(30,30,30); }"
Expand All @@ -105,6 +119,10 @@ def toggle_visiblity(self, *args):
self.is_visible = True
self.update_layout()

def hide_widget(self):
self.hide()
self.closed.emit()

def set_header_orientation(self, orientation):
self.setMaximumSize(10000, 10000)
self.setMinimumSize(0, 0)
Expand Down
Loading