From a830b6b27fe9dc5433ba00cda1f5306fc21939c0 Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Thu, 15 Jan 2026 16:43:03 -0700 Subject: [PATCH] Add fallback handling for missing icon files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add graceful fallback behavior when icon image files (refresh.png, settings.png, MSMD32.png) are not found. The application now uses Unicode symbols (⟳, ⚙) as button text alternatives, preventing crashes when running without bundled assets. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .claude/settings.local.json | 12 +++++++++++- MSMD_multiLevel.py | 21 +++++++++++++++------ Settings.py | 4 +++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 9a30977..287e348 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -6,7 +6,17 @@ "Bash(pip install:*)", "Bash(python:*)", "Bash(git init:*)", - "Bash(git add:*)" + "Bash(git add:*)", + "Bash(cat:*)", + "Bash(git commit:*)", + "Bash(git push:*)", + "Bash(ls:*)", + "Bash(git tag:*)", + "Bash(pyinstaller:*)", + "Bash(open:*)", + "Bash(osascript:*)", + "Bash(killall:*)", + "Bash(git fetch:*)" ] } } diff --git a/MSMD_multiLevel.py b/MSMD_multiLevel.py index e884851..79cecf9 100644 --- a/MSMD_multiLevel.py +++ b/MSMD_multiLevel.py @@ -175,14 +175,22 @@ class App(QWidget): self.portRefreshButton = QPushButton(self) self.portRefreshButton.setToolTip('Press to detect port of connected base station') self.portRefreshButton.clicked.connect(self.refreshPorts) - self.portRefreshButton.setIcon(QIcon('refresh.png')) - self.portRefreshButton.setFixedWidth(24) - + if os.path.exists('refresh.png'): + self.portRefreshButton.setIcon(QIcon('refresh.png')) + self.portRefreshButton.setFixedWidth(24) + else: + self.portRefreshButton.setText('⟳') + self.portRefreshButton.setFixedWidth(30) + self.settingsButton = QPushButton() self.settingsButton.setToolTip('Open the Settings Dialog') - self.settingsButton.setIcon(QIcon('settings.png')) - self.settingsButton.setMaximumWidth(24) self.settingsButton.clicked.connect(self.openSettings) + if os.path.exists('settings.png'): + self.settingsButton.setIcon(QIcon('settings.png')) + self.settingsButton.setMaximumWidth(24) + else: + self.settingsButton.setText('⚙') + self.settingsButton.setMaximumWidth(30) self.connected = False self.refreshPorts() @@ -269,7 +277,8 @@ class App(QWidget): self.setLayout(self.stackedLayout) self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) - self.setWindowIcon(QIcon('MSMD32.png')) + if os.path.exists('MSMD32.png'): + self.setWindowIcon(QIcon('MSMD32.png')) self.cleanupEvent.connect(self.cleanupStuff) self.show() self.bringToFront() diff --git a/Settings.py b/Settings.py index 750fd6c..f827279 100644 --- a/Settings.py +++ b/Settings.py @@ -25,7 +25,9 @@ class Settings(QWidget): self.__UserAbort = True #-----Widget Settings----- - self.setWindowIcon(QIcon('MSMD32.png')) + import os + if os.path.exists('MSMD32.png'): + self.setWindowIcon(QIcon('MSMD32.png')) self.setWindowTitle('MSMD Settings') #Remove Maximize and Minimize buttons