Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
77cb3d7
Redirected the 'home page' link to labgym.org instead of the labgym g…
alisaficiciyan Mar 3, 2026
1bcc859
Added the link to LabGym youtube tutorial describing preprocessing ba…
alisaficiciyan Mar 11, 2026
4f88a46
Added the link to the LabGym youtube tutorial describing how to draw …
alisaficiciyan Mar 24, 2026
a438bcb
Added the link to the LabGym youtube tutorial describing background s…
alisaficiciyan Mar 24, 2026
90f1b70
Added a tab that cannot be closed which includes the visuals of the L…
alisaficiciyan May 18, 2026
7b4bdb9
Made the font size larger for all text in the workflow map
alisaficiciyan May 19, 2026
67efa02
Changed the layout of the workflow map to better represent the workflow
alisaficiciyan May 19, 2026
db12725
Updated the workflow map to use fixed pixels instead of changing the …
alisaficiciyan May 28, 2026
a1d57b9
Changed the colors of the workflow map so that it is easy to distingu…
alisaficiciyan Jun 1, 2026
316866c
Changed the layout of the workflow so that each of the 3 sections is …
alisaficiciyan Jun 2, 2026
737a217
Made the workflow slightly larger on the screen so it is easier for u…
alisaficiciyan Jun 2, 2026
6b85681
Added a button to all pages in LabGym (except home and workflow map) …
alisaficiciyan Jun 7, 2026
11c5a8d
Standardized the margins in each of the boxes and changed the text so…
alisaficiciyan Jun 10, 2026
a1fe2a2
Added 4th category to the workflow map for post classification analys…
alisaficiciyan Jun 14, 2026
8e49f66
Added a pop-up feature so you can click on each box in the workflow m…
alisaficiciyan Jun 14, 2026
00dd075
Lightened the background of pop-ups; unbolded the titles of the box n…
alisaficiciyan Jun 17, 2026
51eb35e
Added an example count display that shows up after selecting a folder…
alisaficiciyan Jun 27, 2026
d1f1da4
Changed the example count so it is now triggered by adding a folder t…
alisaficiciyan Jul 3, 2026
c66c476
Added a line under each row which specifies how many example counts n…
alisaficiciyan Jul 3, 2026
a60c171
Instead of the whole text box popping up when attaching a folder for …
alisaficiciyan Jul 3, 2026
674ae9e
Added the behavior counts to the sorted behavior examples folder in a…
alisaficiciyan Jul 6, 2026
38b8abf
Added a title to both pop-ups to differentiate the two from each othe…
alisaficiciyan Jul 10, 2026
c9267e9
Added a box within each pop-up that allows users to change the minimi…
alisaficiciyan Jul 10, 2026
124429e
Updated the header of each pop-up to get rid of the header scrollbar …
alisaficiciyan Jul 10, 2026
b18799d
Capitalized the title in one of the workflow map pop-ups
alisaficiciyan Jul 29, 2026
c91faa8
Added youtube tutorial links for the following 2 videos: “Training a …
alisaficiciyan Jul 28, 2026
185d956
fix(gui): remove background subtraction tutorial link
btmlnsn Aug 4, 2026
e08229f
fix(categorizer): improve behavior count popup readability
btmlnsn Aug 4, 2026
686f79e
fix(categorizer): integrate behavior count actions into folder rows
btmlnsn Aug 4, 2026
3d7e196
fix(gui): fit workflow map to fixed window size
btmlnsn Aug 4, 2026
631f3b6
fix(gui): unify and resize runtime application icons
btmlnsn Aug 4, 2026
ce2f12e
feat(gui): detect native light and dark appearance
btmlnsn Aug 4, 2026
5bba162
fix(gui): adapt workflow map to native appearance
btmlnsn Aug 4, 2026
80b0c35
fix(gui): standardize hyperlink styling across LabGym
btmlnsn Aug 4, 2026
236b7c3
feat(gui): add resources link to home page
btmlnsn Aug 4, 2026
737c82b
fix(gui): align AF navigation and count diagnostics
btmlnsn Aug 11, 2026
6b2f69c
fix(tests): initialize mywx before wx imports
btmlnsn Aug 11, 2026
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
4 changes: 4 additions & 0 deletions LabGym/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def main() -> None:
wx.App()
mywx.bring_wxapp_to_foreground()

# Establish Windows AppUserModelID / macOS Dock icon before any
# probe dialog or main window is shown (taskbar process identity only).
gui_main.setup_application_icons()

# Perform some pre-op sanity checks and probes of outside resources.
probes.probes()

Expand Down
Binary file modified LabGym/assets/icons/labgym.icns
Binary file not shown.
Binary file modified LabGym/assets/icons/labgym.ico
Binary file not shown.
Binary file modified LabGym/assets/icons/labgym.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions LabGym/gui_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from LabGym import config
from .minedata import data_mining
from .tools import plot_events, parse_all_events_file, calculate_distances
from .gui_utils import add_info_button, INFO_COLOUR_S3, INFO_COLOUR_S4


class ColorPicker(wx.Dialog):
Expand Down Expand Up @@ -142,6 +143,7 @@ def display_window(self):

panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)
add_info_button(self, boxsizer, INFO_COLOUR_S3)

module_selectcategorizer=wx.BoxSizer(wx.HORIZONTAL)
button_selectcategorizer=wx.Button(panel,label='Select a Categorizer for\nbehavior classification',size=(300,40))
Expand Down Expand Up @@ -1134,6 +1136,7 @@ def display_window(self):

panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)
add_info_button(self, boxsizer, INFO_COLOUR_S4)

module_inputfolder=wx.BoxSizer(wx.HORIZONTAL)
button_inputfolder=wx.Button(panel,label='Select the folder that contains\nthe LabGym analysis output folders',size=(300,40))
Expand Down Expand Up @@ -1309,6 +1312,7 @@ def display_window(self):

panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)
add_info_button(self, boxsizer, INFO_COLOUR_S4)

module_inputfile=wx.BoxSizer(wx.HORIZONTAL)
button_inputfile=wx.Button(panel,label='Select the\nall_events.xlsx file',size=(300,40))
Expand Down Expand Up @@ -1425,6 +1429,7 @@ def display_window(self):

panel = self
boxsizer=wx.BoxSizer(wx.VERTICAL)
add_info_button(self, boxsizer, INFO_COLOUR_S4)

module_inputfolder=wx.BoxSizer(wx.HORIZONTAL)
button_inputfolder=wx.Button(panel,label='Select the folder that stores\nLabGym analysis results',size=(300,40))
Expand Down
94 changes: 59 additions & 35 deletions LabGym/gui_app_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
'''

'''GUI application icon module for LabGym.
This module provides cross-platform icon handling functionality for the LabGym
GUI, including support for different icon formats (ICO, ICNS, PNG) and
contexts (normal, small).
This module provides cross-platform icon handling for the LabGym GUI using one
simplified LabGym artwork set (ICO on Windows, PNG elsewhere, ICNS on macOS Dock).
'''
# Standard library imports.
import logging
import sys
from pathlib import Path
from importlib.resources import files
Expand All @@ -36,84 +36,108 @@
from AppKit import NSApplication, NSImage
except ImportError:
NSApplication = None
NSImage = None

logger = logging.getLogger(__name__)


@lru_cache(maxsize=1)
def _get_icon_paths():
"""Get all icon paths once and cache them."""
base_path = files("LabGym") / "assets/icons"
return {
'small_ico': base_path / "labgym_small.ico",
'main_ico': base_path / "labgym.ico",
'ico': base_path / "labgym.ico",
'icns': base_path / "labgym.icns",
'png': base_path / "labgym.png"
'png': base_path / "labgym.png",
}


def get_icon_for_context(context='normal', size=16):
"""Get appropriate icon path for given context and size."""
def get_frame_icon_path():
"""Return the platform-appropriate path for wx frame icons.

Windows uses the multi-resolution labgym.ico. macOS and other platforms
use the matching labgym.png.
"""
icon_paths = _get_icon_paths()

if sys.platform.startswith("win"):
# Windows: Use ICO files for better compatibility
if context == 'small' or size <= 24:
return str(icon_paths['small_ico']) if icon_paths['small_ico'].is_file() else str(icon_paths['png'])
else:
return str(icon_paths['main_ico']) if icon_paths['main_ico'].is_file() else str(icon_paths['png'])
if icon_paths['ico'].is_file():
return str(icon_paths['ico'])
if icon_paths['png'].is_file():
return str(icon_paths['png'])
return ""

# macOS or fallback
return str(icon_paths['png']) if icon_paths['png'].is_file() else ""
# macOS and non-Windows fallback
if icon_paths['png'].is_file():
return str(icon_paths['png'])
return ""


def set_frame_icon(frame, context='normal', size=16):
"""Set frame icon with proper error handling."""
def set_frame_icon(frame):
"""Set the frame icon from the unified simplified artwork."""
try:
icon_path = get_icon_for_context(context, size)
icon_path = get_frame_icon_path()
if not icon_path or not Path(icon_path).is_file():
logger.warning('Frame icon asset not found')
return

icon = wx.Icon(icon_path, wx.BITMAP_TYPE_ANY)
if icon.IsOk():
frame.SetIcon(icon)
else:
logger.warning('Failed to load frame icon from %s', icon_path)
except Exception:
pass
logger.exception('Error setting frame icon')


def set_windows_app_user_model_id():
"""Establish Windows process/taskbar identity via AppUserModelID.

def set_windows_taskbar_icon():
"""Set the Windows taskbar icon.
Set the Windows taskbar icon using small ICO for better small-size
visibility.
Call this early (before the first visible window) when practical.
This does not embed an executable icon; it only sets runtime process
identity used by the shell for taskbar grouping.
"""
if not sys.platform.startswith("win"):
return
try:
# This sets AppUserModelID first - this is crucial for proper taskbar icon association
app_id = "umyelab.LabGym"
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
except Exception:
pass
logger.exception('Failed to set Windows AppUserModelID')


# Backward-compatible name used by older call sites.
set_windows_taskbar_icon = set_windows_app_user_model_id


def set_macos_dock_icon():
"""Set the Dock icon on macOS.
Set the Dock icon at runtime on macOS (requires optional PyObjC).
"""
"""Set the Dock icon on macOS for unbundled runs (optional PyObjC)."""
if sys.platform != "darwin" or not NSApplication:
return
try:
baseIconDir = files("LabGym")
icns = baseIconDir / "assets/icons/labgym.icns"
png = baseIconDir / "assets/icons/labgym.png"
icon_paths = _get_icon_paths()
if icon_paths['icns'].is_file():
icon_path = str(icon_paths['icns'])
elif icon_paths['png'].is_file():
icon_path = str(icon_paths['png'])
else:
logger.warning('macOS Dock icon asset not found')
return

icon_path = str(icns if icns.is_file() else png)
img = NSImage.alloc().initWithContentsOfFile_(icon_path)
if img:
NSApplication.sharedApplication().setApplicationIconImage_(img)
else:
logger.warning('Failed to load macOS Dock icon from %s', icon_path)
except Exception:
pass
logger.exception('Error setting macOS Dock icon')


def setup_application_icons():
"""Set up all application icons for the current platform."""
"""Set up process/Dock icons for the current platform.

Safe to call more than once. Prefer an early call before the first
visible window so Windows AppUserModelID is established first.
"""
set_windows_app_user_model_id()
set_macos_dock_icon()
set_windows_taskbar_icon()
98 changes: 98 additions & 0 deletions LabGym/gui_appearance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
'''
Copyright (C)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)#fulltext.

For license issues, please contact:

Dr. Bing Ye
Life Sciences Institute
University of Michigan
210 Washtenaw Avenue, Room 5403
Ann Arbor, MI 48109-2216
USA

Email: bingye@umich.edu
'''


'''Native appearance helpers for LabGym.

Reports whether the OS / wxPython effective appearance is dark so callers can
pick appearance-dependent values (e.g. colours). Does not implement a custom
theme, Light/Dark/System override, preference persistence, or widget recoloring.
'''

import wx


def _colour_luminance(colour) -> float:
"""Return approximate relative luminance of a wx colour (0–255 scale)."""
try:
r, g, b = colour.Red(), colour.Green(), colour.Blue()
except Exception:
try:
r, g, b = colour.Get()[:3]
except Exception:
return 128.0
# ITU-R BT.601 luma coefficients, full 8-bit channel range.
return 0.299 * r + 0.587 * g + 0.114 * b


def _is_dark_from_system_colours() -> bool:
"""Infer dark appearance by comparing system window background vs text."""
bg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
fg = wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT)
return _colour_luminance(bg) < _colour_luminance(fg)


def is_dark_appearance() -> bool:
"""Return True when the effective native wx appearance is dark.

Detection order:
1. ``wx.SystemSettings.GetAppearance().IsDark()`` when available.
2. ``GetAppearance().IsUsingDarkBackground()`` when ``IsDark`` is missing
or raises (older / partial APIs).
3. System window vs window-text luminance when the appearance API is
unavailable or fails.
4. Light (``False``) as a final safe default.
"""
get_appearance = getattr(wx.SystemSettings, 'GetAppearance', None)
if callable(get_appearance):
try:
appearance = get_appearance()
except Exception:
appearance = None

if appearance is not None:
is_dark = getattr(appearance, 'IsDark', None)
if callable(is_dark):
try:
return bool(is_dark())
except Exception:
pass

# Fallback / older builds: IsUsingDarkBackground without IsDark.
is_using_dark_bg = getattr(appearance, 'IsUsingDarkBackground', None)
if callable(is_using_dark_bg):
try:
return bool(is_using_dark_bg())
except Exception:
pass

try:
return bool(_is_dark_from_system_colours())
except Exception:
return False


def select_for_appearance(light_value, dark_value):
"""Return ``dark_value`` under dark native appearance, else ``light_value``.

Values may be ``wx.Colour`` instances or any other small appearance-dependent
objects; this helper does not inspect or convert them.
"""
if is_dark_appearance():
return dark_value
return light_value
Loading
Loading