diff --git a/src/coastseg/coastseg_map.py b/src/coastseg/coastseg_map.py index 6703c99d..e9aa5c71 100644 --- a/src/coastseg/coastseg_map.py +++ b/src/coastseg/coastseg_map.py @@ -137,39 +137,6 @@ def find_shorelines_directory(path, roi_id): return None -def find_shorelines_directory(path, roi_id): - # List the contents of the specified path - contents = os.listdir(path) - - # Check for extracted shorelines geojson file in the specified path - extracted_shorelines_file = [ - file - for file in contents - if "extracted_shorelines" in file and file.endswith(".geojson") - ] - if extracted_shorelines_file: - return path - - # If the file is not found, check for a directory with the ROI ID - roi_directory = [ - directory - for directory in contents - if os.path.isdir(os.path.join(path, directory)) and roi_id in directory - ] - if roi_directory: - roi_path = os.path.join(path, roi_directory[0]) - roi_contents = os.listdir(roi_path) - extracted_shorelines_file = [ - file - for file in roi_contents - if "extracted_shorelines" in file and file.endswith(".geojson") - ] - if extracted_shorelines_file: - return roi_path - - return None - - def delete_extracted_shorelines_files(session_path: str, selected_items: List): """ Delete the extracted shorelines from the session directory for all the relevant files. @@ -278,7 +245,7 @@ def _init_info_boxes(self): self.map.add(self.warning_widget) self.roi_html = HTML("""""") - self.roi_box = common.create_hover_box(title="ROI", feature_html=self.roi_html) + self.roi_box = common.create_hover_box(title="ROI", feature_html=self.roi_html,default_msg="Hover over a ROI") self.roi_widget = WidgetControl(widget=self.roi_box, position="topright") self.map.add(self.roi_widget) diff --git a/src/coastseg/common.py b/src/coastseg/common.py index 4c665dea..ce07a00d 100644 --- a/src/coastseg/common.py +++ b/src/coastseg/common.py @@ -1704,7 +1704,7 @@ def mount_google_drive(name: str = "CoastSeg") -> None: print("Not running in Google Colab.") -def create_hover_box(title: str, feature_html: HTML = HTML("")) -> VBox: +def create_hover_box(title: str, feature_html: HTML = HTML(""),default_msg: str = "Hover over a feature") -> VBox: """ Creates a box with a title and optional HTML containing information about the feature that was last hovered over. @@ -1720,26 +1720,28 @@ def create_hover_box(title: str, feature_html: HTML = HTML("")) -> VBox: Returns: container (VBox): Box with the given title and details about the feature given by feature_html """ - padding = "0px 0px 0px 5px" # upper, right, bottom, left + padding = "0px 0px 4px 0px" # upper, right, bottom, left # create title - title = HTML(f"

{title} Hover

") + # title = HTML(f"{title}") + title_html = HTML(f"{title}", layout=Layout(margin="0px 8px")) # Adjust 10px as needed for left and right margins + # Default message shown when nothing has been hovered - msg = HTML(f"Hover over a feature
") + msg = HTML(f"{default_msg}
") # open button allows user to see hover data uncollapse_button = ToggleButton( value=False, tooltip="Show hover data", icon="angle-down", - button_style="info", + button_style='primary', layout=Layout(height="28px", width="28px", padding=padding), ) # collapse_button collapses hover data - collapse_button = ToggleButton( + close_button = ToggleButton( value=False, - tooltip="Show hover data", - icon="angle-up", - button_style="info", + tooltip="Close", + icon="times", + button_style="danger", layout=Layout(height="28px", width="28px", padding=padding), ) @@ -1751,7 +1753,7 @@ def create_hover_box(title: str, feature_html: HTML = HTML("")) -> VBox: container_content.children = [feature_html] # default configuration for container is in collapsed mode - container_header = HBox([title, uncollapse_button]) + container_header = HBox([uncollapse_button,title_html]) container = VBox([container_header]) def uncollapse_click(change: dict): @@ -1759,14 +1761,14 @@ def uncollapse_click(change: dict): container_content.children = [msg] elif feature_html.value != "": container_content.children = [feature_html] - container_header.children = [title, collapse_button] + container_header.children = [close_button,title_html] container.children = [container_header, container_content] def collapse_click(change: dict): - container_header.children = [title, uncollapse_button] + container_header.children = [uncollapse_button,title_html] container.children = [container_header] - collapse_button.observe(collapse_click, "value") + close_button.observe(collapse_click, "value") uncollapse_button.observe(uncollapse_click, "value") return container