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

Keyword args #108

Merged
merged 4 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
87 changes: 28 additions & 59 deletions brainreg_segment/layout/gui_elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# GUI ELEMENTS
# from napari.resources import build_icons # Contains .SVGPATH to all icons
# for napari

from qtpy.QtWidgets import (
QCheckBox,
QComboBox,
Expand All @@ -16,8 +12,8 @@ def add_combobox(
layout,
label,
items,
row,
column=0,
row: int = 0,
column: int = 0,
label_stack=False,
callback=None,
width=150,
Expand Down Expand Up @@ -50,8 +46,8 @@ def add_button(
layout,
connected_function,
*,
row: int,
column: int,
row: int = 0,
column: int = 0,
visibility=True,
minimum_width=0,
alignment="center",
Expand All @@ -71,55 +67,13 @@ def add_button(
return button


# def add_radiobutton(
# label,
# layout,
# connected_function,
# row,
# column,
# visibility=True,
# minimum_width=0,
# alignment="center",
# ):
# button = QRadioButton(label)
# if alignment == "center":
# pass
# elif alignment == "left":
# button.setStyleSheet(
# "QRadioButton { text-align: left; padding: 0; spacing: 30px;}"
# )
# elif alignment == "right":
# button.setStyleSheet(
# "QRadioButton { text-align: right; padding: 0; spacing: 30px;}"
# )

# # Too change indicator button ... needs to dynamically retrieve icon
# # from Napari.
# # Icons are saved as .svg files under napari.resources SVGPATH
# # "QRadioButton::indicator"
# # "{"
# # "width:16px;"
# # "height:16px;"
# # "}"
# # "QRadioButton::indicator::unchecked"
# # "{"
# # "image: url(build_icons.SVGPATH/visibility_off.svg);"
# # "}"
# # "QRadioButton::indicator::checked"
# # "{"
# # "image: url(/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/
# napari/resources/icons/visibility.svg);"
# # "}"
# # )

# button.setVisible(visibility)
# button.setMinimumWidth(minimum_width)
# layout.addWidget(button, row, column)
# button.clicked.connect(connected_function)
# return button


def add_checkbox(layout, default, label, row, column=0):
def add_checkbox(
layout,
default,
label,
row: int = 0,
column: int = 0,
):
box = QCheckBox()
box.setChecked(default)
layout.addWidget(QLabel(label), row, column)
Expand All @@ -128,7 +82,14 @@ def add_checkbox(layout, default, label, row, column=0):


def add_float_box(
layout, default, minimum, maximum, label, step, row, column=0
layout,
default,
minimum,
maximum,
label,
step,
row: int = 0,
column: int = 0,
):
box = QDoubleSpinBox()
box.setMinimum(minimum)
Expand All @@ -140,7 +101,15 @@ def add_float_box(
return box


def add_int_box(layout, default, minimum, maximum, label, row, column=0):
def add_int_box(
layout,
default,
minimum,
maximum,
label,
row: int = 0,
column: int = 0,
):
box = QSpinBox()
box.setMinimum(minimum)
box.setMaximum(maximum)
Expand Down
4 changes: 2 additions & 2 deletions brainreg_segment/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def add_atlas_menu(self, layout):
layout,
None,
list_of_atlasses,
2,
0,
row=2,
column=0,
label_stack=True,
callback=self.initialise_atlas,
width=COLUMN_WIDTH,
Expand Down
4 changes: 2 additions & 2 deletions brainreg_segment/segmentation_panels/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ def add_region_panel(self, row):
region_layout,
self.calculate_volumes_default,
"Calculate volumes",
0,
row=0,
)

self.summarise_volumes_checkbox = add_checkbox(
region_layout,
self.summarise_volumes_default,
"Summarise volumes",
1,
row=1,
)

region_layout.setColumnMinimumWidth(1, COLUMN_WIDTH)
Expand Down
8 changes: 4 additions & 4 deletions brainreg_segment/segmentation_panels/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def add_track_panel(self, row):
track_layout,
self.summarise_track_default,
"Summarise",
0,
row=0,
)

self.fit_degree = add_int_box(
Expand All @@ -119,7 +119,7 @@ def add_track_panel(self, row):
1,
5,
"Fit degree",
1,
row=1,
)

self.spline_smoothing = add_float_box(
Expand All @@ -129,7 +129,7 @@ def add_track_panel(self, row):
1,
"Spline smoothing",
0.1,
2,
row=2,
)

self.spline_points = add_int_box(
Expand All @@ -138,7 +138,7 @@ def add_track_panel(self, row):
1,
10000,
"Spline points",
3,
row=3,
)

track_layout.setColumnMinimumWidth(1, COLUMN_WIDTH)
Expand Down
Loading