Skip to content

Commit

Permalink
Fix bulletin dialog display conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
shrivaths16 committed Dec 5, 2023
1 parent 793faa6 commit 561a109
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/bulletin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"title": "SLEAP v1.3.2",
"date": "10/30/2023",
"date": "12/8/2023",
"content": "\n\n\nSLEAP 1.3.2 adds some nice usability features thanks to both the community ideas and new contributors! See [1.3.0](https://github.com/talmolab/sleap/releases/tag/v1.3.0) and [1.3.1](https://github.com/talmolab/sleap/releases/tag/v1.3.1) for previous notable changes. As a reminder:\n\n> The 1.3.1 dependency update requires [Mamba](https://mamba.readthedocs.io/en/latest/index.html) for faster dependency resolution. If you already have anaconda installed, then you _can_ set the solver to libmamba in the base environment:\n>```\n>conda update -n base conda\n>conda install -n base conda-libmamba-solver\n>conda config --set solver libmamba\n>```\n>Any subsequent `mamba` commands in the docs will need to be replaced with `conda` if you choose to use your existing Anaconda installation. \n>\n>Otherwise, follow the [recommended installation instruction for Mamba](https://mamba.readthedocs.io/en/latest/installation.html).\n\n### Quick install\n**`mamba` (Windows/Linux/GPU)**:\n```\nmamba create -y -n sleap -c conda-forge -c nvidia -c sleap -c anaconda sleap=1.3.2\n```\n\n**`mamba` (Mac)**:\n```\nmamba create -y -n sleap -c conda-forge -c anaconda -c sleap sleap=1.3.2\n```\n\n**`pip` (any OS except Apple Silicon)**:\n```\npip install sleap[pypi]==1.3.2\n```\n\n### Highlights\n* Limit max tracks via track-local queues by @shrivaths16 and @talmo in https://github.com/talmolab/sleap/pull/1447\n* Add option to remove videos in batch by @gitttt-1234 in https://github.com/talmolab/sleap/pull/1382 and https://github.com/talmolab/sleap/pull/1406\n* Add shortcut to export analysis for current video by @KevinZ0217 in https://github.com/talmolab/sleap/pull/1414 and https://github.com/talmolab/sleap/pull/1444\n* Add video path and frame indices to metrics by @roomrys in https://github.com/talmolab/sleap/pull/1396\n* Add a button for copying model config to clipboard by @KevinZ0217 in https://github.com/talmolab/sleap/pull/1433\n* Add Option to Export CSV by @gitttt-1234 in https://github.com/talmolab/sleap/pull/1438\n\n### Full Changelog\n\n#### Enhancements\n* Add option to remove videos in batch by @gitttt-1234 in https://github.com/talmolab/sleap/pull/1382 and https://github.com/talmolab/sleap/pull/1406\n* Add `Track` when add `Instance` by @roomrys in https://github.com/talmolab/sleap/pull/1408\n* Add `Video` to cache when adding `Track` by @roomrys in https://github.com/talmolab/sleap/pull/1407\n* Add shortcut to export analysis for current video by @KevinZ0217 in https://github.com/talmolab/sleap/pull/1414 and https://github.com/talmolab/sleap/pull/1444\n* Add video path and frame indices to metrics by @roomrys in https://github.com/talmolab/sleap/pull/1396\n* Improve error message for detecting video backend by @roomrys in https://github.com/talmolab/sleap/pull/1441\n* Add a button for copying model config to clipboard by @KevinZ0217 in https://github.com/talmolab/sleap/pull/1433\n* Add Option to Export CSV by @gitttt-1234 in https://github.com/talmolab/sleap/pull/1438\n* Limit max tracks via track-local queues by @shrivaths16 and @talmo in https://github.com/talmolab/sleap/pull/1447\n\n#### Fixes\n* Minor fix in computation of OKS by @shrivaths16 in https://github.com/talmolab/sleap/pull/1383 and https://github.com/talmolab/sleap/pull/1399\n* Fix `Filedialog` to work across (mac)OS by @roomrys in https://github.com/talmolab/sleap/pull/1393\n* Fix panning bounding box by @gitttt-1234 in https://github.com/talmolab/sleap/pull/1398\n* Fix skeleton templates by @roomrys in https://github.com/talmolab/sleap/pull/1404\n* Fix labels export for json by @roomrys in https://github.com/talmolab/sleap/pull/1410\n* Correct GUI state emulation by @roomrys in https://github.com/talmolab/sleap/pull/1422\n* Update status message on status bar by @shrivaths16 in https://github.com/talmolab/sleap/pull/1411\n* Fix error thrown when last video is deleted by @shrivaths16 in https://github.com/talmolab/sleap/pull/1421\n* Add model folder to the unzip path by @roomrys in https://github.com/talmolab/sleap/pull/1445\n* Fix drag and drop by @talmo in https://github.com/talmolab/sleap/pull/1449\n\n#### Dependencies\n* Pin micromamba version by @roomrys in https://github.com/talmolab/sleap/pull/1376\n* Add pip extras by @roomrys in https://github.com/talmolab/sleap/pull/1481\n\n#### New Contributors\n* @shrivaths16 made their first contribution in https://github.com/talmolab/sleap/pull/1383\n* @gitttt-1234 made their first contribution in https://github.com/talmolab/sleap/pull/1382\n* @KevinZ0217 made their first contribution in https://github.com/talmolab/sleap/pull/1414\n\n**Full Changelog**: https://github.com/talmolab/sleap/compare/v1.3.1...v1.3.2\n"
}
]
37 changes: 10 additions & 27 deletions sleap/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,6 @@ def __init__(
self.state["skeleton_preview_image"] = None
self.state["skeleton_description"] = "No skeleton loaded yet"

if prefs["announcement last seen date"]:
self.state["announcement last seen date"] = prefs[
"announcement last seen date"
]
else:
self.state["announcement last seen date"] = date.today().strftime(
"%m/%d/%Y"
)

if prefs["announcement"]:
self.state["announcement"] = prefs["announcement"]
else:
self.state["announcement"] = "No data to display"

if no_usage_data:
self.state["share usage data"] = False
self.state["clipboard_track"] = None
Expand All @@ -186,8 +172,10 @@ def __init__(

self.release_checker = ReleaseChecker()

self.state["announcement last seen date"] = prefs["announcement last seen date"]
self.state["announcement"] = prefs["announcement"]

self.announcement_checker = AnnouncementChecker(state=self.state)
self.new_announcement_available = self.announcement_checker.new_announcement

if self.state["share usage data"]:
ping_analytics()
Expand All @@ -209,23 +197,18 @@ def __init__(
self.state["project_loaded"] = False

# Display announcement bulletin popup
if self.new_announcement_available:
if self.announcement_checker.new_announcement_available():
self.bulletin_dialog()
self.announcement_checker.update_announcement()

def bulletin_dialog(self):
"""Displays bulletin dialog is new announcement is available."""
announcement = self.announcement_checker.get_latest_announcement()

if announcement:
title, date, content = announcement
bulletin_markdown = "\n".join(content.split("\n"))

# initialize the bulletin popup worker
popup_worker = BulletinWorker(bulletin_markdown, self)
popup_worker.show_bulletin()
# Initialize the bulletin popup worker
popup_worker = BulletinWorker(self.state["announcement"], self)
popup_worker.show_bulletin()

# Save the bulletin worker so we can close them later
self._child_windows["bulletin_worker"] = popup_worker # Needed!
# Save the bulletin worker so we can close them later
self._child_windows["bulletin_worker"] = popup_worker # Needed!

def setWindowTitle(self, value):
"""Sets window title (if value is not None)."""
Expand Down
23 changes: 11 additions & 12 deletions sleap/gui/dialogs/bulletin/markdown.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body {
margin: 0 auto;
font-family: Georgia, Palatino, serif;
color: #444444;
font-family: Helvetica, Arial, Sans-Serif;
color: #000000;
line-height: 1;
max-width: 960px;
padding: 30px;
Expand All @@ -11,8 +11,7 @@ h1,
h2,
h3,
h4 {
color: #111111;
font-weight: 400;
font-weight: 600;
}

h1,
Expand All @@ -26,42 +25,42 @@ p {
}

h1 {
font-size: 48px;
font-size: 50px;
}

h2 {
font-size: 36px;
font-size: 38px;
/* The bottom margin is small. It's designed to be used with gray meta text
* below a post title. */
margin: 24px 0 6px;
}

h3 {
font-size: 24px;
font-size: 26px;
}

h4 {
font-size: 21px;
font-size: 22px;
}

h5 {
font-size: 18px;
font-size: 20px;
}

a {
color: #0099ff;
color: #0099ffd5;
margin: 0;
padding: 0;
vertical-align: baseline;
}

a:hover {
text-decoration: none;
color: #ff6600;
color: #ff6600b7;
}

a:visited {
color: purple;
color: rgba(128, 0, 128, 0.815);
}

ul,
Expand Down
10 changes: 10 additions & 0 deletions tests/gui/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@

from sleap.gui.app import MainWindow
from sleap.gui.commands import *
from sleap.gui.dialogs.bulletin import BulletinWorker


def test_app_workflow(
qtbot, centered_pair_vid, small_robot_mp4_vid, min_tracks_2node_labels: Labels
):
app = MainWindow(no_usage_data=True)

# Check if the bulletin is shown or not
bulletin_dialog = app._child_windows.get("bulletin_worker", False)
if app.announcement_checker.new_announcement_available():
print("bulletin available")
assert isinstance(bulletin_dialog, BulletinWorker)
else:
print("no bulletin")
assert bulletin_dialog == False

# Add nodes
app.commands.newNode()
app.commands.newNode()
Expand Down

0 comments on commit 561a109

Please sign in to comment.