-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
611 lines (520 loc) · 25.3 KB
/
Copy pathmain.py
File metadata and controls
611 lines (520 loc) · 25.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
"""
Mushroom Collection System (main.py)
------------------------------------
This application provides a graphical interface for field mycologists to catalog mushroom specimens.
Users can enter specimen data (location, species, habitat, etc.), generate a unique ID,
and print 2x2 QR-coded labels in both PDF and PNG formats.
Features:
- Quick entry of multiple specimens under a shared location
- Automatic QR code generation with embedded specimen data
- Optional export of the full database to Excel
- Integrated message feedback and visual error/success indicators
Usage Notes:
- "Set Current Location" saves reusable location data for faster batch entry
- All fields are saved to an SQLite database as strings
- iNaturalist ID is optional but validated as numeric
(c) 2025 j Simmons. All rights reserved.
MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
"""
import os
import sys
import json
import qrcode
from PySide6.QtGui import QPixmap, QFont, QIcon
from PySide6.QtWidgets import (
QApplication, QWidget, QLabel, QLineEdit, QVBoxLayout, QHBoxLayout, QPushButton,
QDateEdit, QGroupBox, QFormLayout, QRadioButton, QButtonGroup, QCheckBox, QSplashScreen,
QTextEdit
)
from PySide6.QtCore import Qt, QDate
from apps.catalog_data import init_db, insert_specimen, export_to_excel, get_next_unique_id
from apps.label_utils import print_label_with_qrcode
from apps.utils import ensure_dir, logger, app_root, resource_path
APP_VERSION = "v1.3"
DEBUG = True
DEFAULT_REQUIRED_FIELDS = [
"date", "state", "county", "city", "site_name", "species", "collected_by"
]
class MycoCatalog(QWidget):
def __init__(self):
super().__init__()
self.setWindowIcon(QIcon(resource_path("blank.ico")))
self.setWindowTitle("")
self.setMinimumWidth(720)
self.current_location = {}
self.required_fields = self.load_required_fields()
self.init_ui()
def load_required_fields(self):
# Use app_root() to get the correct application directory
config_path = os.path.join(app_root(), "validation_config.json")
if(DEBUG):
logger.info(f"[INFO] Configuration load path: {config_path}")
try:
with open(config_path, "r") as f:
data = json.load(f)
if not isinstance(data, dict) or "required_fields" not in data:
raise ValueError("Invalid structure")
self.startup_hint = "Ready. (Custom field validation found)."
# Load record prefix if available, otherwise use default
self.record_prefix = data.get("record_prefix", "NTMA")
return data["required_fields"]
except FileNotFoundError:
self.startup_hint = "Ready. (Default field validation used)."
self.record_prefix = "NTMA"
return DEFAULT_REQUIRED_FIELDS
except Exception as e:
self.startup_error = "Configuration file error: using default validation fields."
self.record_prefix = "NTMA"
return DEFAULT_REQUIRED_FIELDS
def init_ui(self):
main_layout = QVBoxLayout()
main_layout.setSpacing(8) # Reduce spacing between widgets
main_layout.setContentsMargins(10, 10, 10, 10) # Reduce margins
# Header with compact icon and title
self.header_widget = QWidget()
header_layout = QHBoxLayout(self.header_widget)
header_layout.setContentsMargins(5, 5, 5, 5) # Reduce margins
icon_label = QLabel()
icon_file = 'mushroom_icon.icns' if sys.platform == 'darwin' else 'mushroom_icon.ico'
icon_pixmap = QPixmap(resource_path(icon_file)).scaled(48, 48, Qt.KeepAspectRatio, Qt.SmoothTransformation)
#icon_pixmap = QPixmap(resource_path('mushroom_icon.ico')).scaled(48, 48, Qt.KeepAspectRatio, Qt.SmoothTransformation)
icon_label.setPixmap(icon_pixmap)
icon_label.setFixedSize(70, 48) # Increased width to prevent compression of 48x48 icon
icon_label.setAlignment(Qt.AlignCenter) # Center the icon in its space
self.title_label = QLabel('MushLog')
self.title_label.setObjectName("headerTitle")
title_font = QFont()
title_font.setPointSize(24) # Reduced from 32
title_font.setBold(True)
self.title_label.setFont(title_font)
header_layout.addWidget(icon_label)
header_layout.addSpacing(12) # Increased spacing between icon and title
header_layout.addWidget(self.title_label)
header_layout.addStretch()
version_label = QLabel(APP_VERSION)
version_label.setStyleSheet("color: gray; font-size: 12px; padding-right: 6px;") # Reduced from 14px
version_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
header_layout.addWidget(version_label)
main_layout.addWidget(self.header_widget)
main_layout.addSpacing(5) # Reduced from 10
# Record Prefix Configuration
prefix_group = QGroupBox("Record ID Prefix")
prefix_layout = QHBoxLayout()
prefix_label = QLabel("Specimen ID Prefix:")
self.prefix_input = QLineEdit()
self.prefix_input.setText(self.record_prefix)
self.prefix_input.setFixedWidth(100)
self.prefix_input.setPlaceholderText("e.g., NTMA")
# Add save button for prefix
save_prefix_btn = QPushButton("Save Prefix")
save_prefix_btn.setObjectName("primaryButton")
save_prefix_btn.clicked.connect(self.save_prefix_config)
prefix_layout.addWidget(prefix_label)
prefix_layout.addWidget(self.prefix_input)
prefix_layout.addWidget(save_prefix_btn)
prefix_layout.addStretch()
prefix_group.setLayout(prefix_layout)
main_layout.addWidget(prefix_group)
content_layout = QHBoxLayout()
# LEFT COLUMN
left_layout = QVBoxLayout()
location_group = QGroupBox("Location Info")
location_form = QFormLayout()
location_form.setVerticalSpacing(4) # Reduce spacing between form rows
self.date_input = QDateEdit()
self.date_input.setDate(QDate.currentDate())
self.date_input.setCalendarPopup(True)
self.state_input = QLineEdit()
self.county_input = QLineEdit()
self.city_input = QLineEdit()
self.site_input = QLineEdit()
location_form.addRow("Date:", self.date_input)
location_form.addRow("State:", self.state_input)
location_form.addRow("County:", self.county_input)
location_form.addRow("City:", self.city_input)
location_form.addRow("Site Name:", self.site_input)
location_group.setLayout(location_form)
self.set_location_btn = QPushButton("Set Current Location")
self.set_location_btn.setObjectName("primaryButton")
self.set_location_btn.clicked.connect(self.set_current_location)
specimen_group = QGroupBox("Specimen Data Entry")
specimen_form = QFormLayout()
specimen_form.setVerticalSpacing(4) # Reduce spacing between form rows
self.species_input = QLineEdit()
self.photo_group = QButtonGroup()
self.photo_yes = QRadioButton("Yes")
self.photo_no = QRadioButton("No")
self.photo_no.setChecked(True)
self.photo_group.addButton(self.photo_yes)
self.photo_group.addButton(self.photo_no)
photo_layout = QHBoxLayout()
photo_layout.addWidget(self.photo_yes)
photo_layout.addWidget(self.photo_no)
specimen_form.addRow("Species:", self.species_input)
specimen_form.addRow("Field Photo Taken:", photo_layout)
self.inat_input = QLineEdit()
self.inat_input.textChanged.connect(self.on_inat_id_changed)
specimen_form.addRow("iNaturalist #:", self.inat_input)
# Add View on iNaturalist button
self.view_inat_btn = QPushButton("View on iNaturalist")
self.view_inat_btn.setObjectName("primaryButton")
self.view_inat_btn.setEnabled(False) # Initially disabled
self.view_inat_btn.clicked.connect(self.view_on_inaturalist)
specimen_form.addRow("", self.view_inat_btn)
specimen_group.setLayout(specimen_form)
trees_group = QGroupBox("Nearby Trees")
self.trees_group = QButtonGroup()
self.tree_hardwood = QRadioButton("Hardwood")
self.tree_conifer = QRadioButton("Conifer")
self.tree_other = QRadioButton("Other")
for btn in [self.tree_hardwood, self.tree_conifer, self.tree_other]:
self.trees_group.addButton(btn)
tree_layout = QVBoxLayout()
tree_layout.setSpacing(2) # Reduce spacing between radio buttons
tree_layout.addWidget(self.tree_hardwood)
tree_layout.addWidget(self.tree_conifer)
tree_layout.addWidget(self.tree_other)
trees_group.setLayout(tree_layout)
left_layout.addWidget(location_group)
left_layout.addWidget(self.set_location_btn)
left_layout.addWidget(specimen_group)
left_layout.addWidget(trees_group)
# RIGHT COLUMN
right_layout = QVBoxLayout()
substrate_group = QGroupBox("Substrate")
self.substrate_group = QButtonGroup()
substrates = ["Wood", "Soil", "Leaf Litter", "Moss", "Needle Duff", "Grass", "Dung", "Other"]
substrate_layout = QVBoxLayout()
substrate_layout.setSpacing(2) # Reduce spacing between radio buttons
for name in substrates:
btn = QRadioButton(name)
self.substrate_group.addButton(btn)
substrate_layout.addWidget(btn)
substrate_group.setLayout(substrate_layout)
habit_group = QGroupBox("Habit")
self.habit_group = QButtonGroup()
habits = ["Single", "Few", "Many"]
habit_layout = QVBoxLayout()
habit_layout.setSpacing(2) # Reduce spacing between radio buttons
for name in habits:
btn = QRadioButton(name)
self.habit_group.addButton(btn)
habit_layout.addWidget(btn)
habit_group.setLayout(habit_layout)
odor_group = QGroupBox("Odor")
self.odor_input = QLineEdit()
odor_layout = QVBoxLayout()
odor_layout.addWidget(self.odor_input)
odor_group.setLayout(odor_layout)
taste_group = QGroupBox("Taste")
self.taste_input = QLineEdit()
taste_layout = QVBoxLayout()
taste_layout.addWidget(self.taste_input)
taste_group.setLayout(taste_layout)
notes_group = QGroupBox("Notes")
self.notes_input = QTextEdit()
self.notes_input.setMaximumHeight(80) # Limit height for multi-line input
notes_layout = QVBoxLayout()
notes_layout.addWidget(self.notes_input)
notes_group.setLayout(notes_layout)
right_layout.addWidget(substrate_group)
right_layout.addWidget(habit_group)
right_layout.addWidget(odor_group)
right_layout.addWidget(taste_group)
right_layout.addWidget(notes_group)
content_layout.addLayout(left_layout)
content_layout.addLayout(right_layout)
main_layout.addLayout(content_layout)
collected_by_container = QWidget()
collected_by_layout = QFormLayout()
collected_by_layout.setFormAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.collected_by_input = QLineEdit()
self.collected_by_input.setFixedWidth(200)
collected_by_label = QLabel("Collected by:")
collected_by_label.setStyleSheet("font-weight: bold;")
collected_by_layout.addRow(collected_by_label, self.collected_by_input)
collected_by_container.setLayout(collected_by_layout)
main_layout.addWidget(collected_by_container)
format_layout = QHBoxLayout()
self.pdf_checkbox = QCheckBox("Generate PDF")
self.pdf_checkbox.setChecked(True)
self.png_checkbox = QCheckBox("Generate PNG")
self.png_checkbox.setChecked(True)
format_layout.addStretch()
format_layout.addWidget(self.pdf_checkbox)
format_layout.addWidget(self.png_checkbox)
format_layout.addStretch()
main_layout.addLayout(format_layout)
button_layout = QHBoxLayout()
self.save_btn = QPushButton("Save Specimen")
self.save_btn.setObjectName("primaryButton")
self.save_btn.clicked.connect(self.save_specimen)
self.export_btn = QPushButton("Export Database to Excel")
self.export_btn.setObjectName("primaryButton")
self.export_btn.clicked.connect(self.export_database)
button_layout.addWidget(self.save_btn)
button_layout.addWidget(self.export_btn)
main_layout.addLayout(button_layout)
self.message_label = QLabel("Ready. Messages will appear here.")
self.message_label.setObjectName("messageLabel")
self.message_label.setProperty("class", "hint")
main_layout.addWidget(self.message_label)
self.footer_label = QLabel("🍄 MushLove Software 🍄")
self.footer_label.setAlignment(Qt.AlignCenter)
self.footer_label.setObjectName("footerLabel")
main_layout.addWidget(self.footer_label)
# Clear all radio button groups on startup
for group in [self.trees_group, self.substrate_group, self.habit_group]:
for btn in group.buttons():
btn.setAutoExclusive(False)
btn.setChecked(False)
btn.setAutoExclusive(True)
self.setLayout(main_layout)
if hasattr(self, "startup_hint"):
self.show_message(self.startup_hint, success=True)
elif hasattr(self, "startup_error"):
self.show_message(self.startup_error, success=False)
def export_database(self):
try:
filename = export_to_excel()
filename_only = os.path.basename(filename)
self.show_message(f"Database exported successfully to {filename_only}", success=True)
except Exception as e:
self.show_message(f"Error exporting database: {str(e)}", success=False)
def show_message(self, text, success=True):
self.message_label.setText(text)
self.message_label.setProperty("class", "success" if success else "error")
self.message_label.style().unpolish(self.message_label)
self.message_label.style().polish(self.message_label)
def set_current_location(self):
self.current_location = {
"date": self.date_input.date().toString("yyyy-MM-dd"),
"state": self.state_input.text(),
"county": self.county_input.text(),
"city": self.city_input.text(),
"site_name": self.site_input.text()
}
self.show_message("Location Info Set", success=True)
def view_on_inaturalist(self):
"""Open the iNaturalist observation in the default browser"""
inat_id = self.inat_input.text().strip()
if inat_id and inat_id.isdigit():
import webbrowser
url = f"https://www.inaturalist.org/observations/{inat_id}"
try:
webbrowser.open(url)
except Exception as e:
self.show_message(f"Could not open browser: {str(e)}", success=False)
else:
self.show_message("Please enter a valid iNaturalist ID first", success=False)
def on_inat_id_changed(self):
"""Enable/disable the View button based on iNaturalist ID input"""
inat_id = self.inat_input.text().strip()
self.view_inat_btn.setEnabled(bool(inat_id and inat_id.isdigit()))
def clear_form(self):
self.species_input.clear()
self.inat_input.clear()
self.photo_yes.setChecked(False)
self.photo_no.setChecked(True)
for group in [self.trees_group, self.substrate_group, self.habit_group]:
for btn in group.buttons():
btn.setAutoExclusive(False)
btn.setChecked(False)
btn.setAutoExclusive(True)
self.odor_input.clear()
self.taste_input.clear()
self.notes_input.clear()
self.collected_by_input.setText("")
self.collected_by_input.repaint()
self.collected_by_input.clearFocus()
self.save_btn.setFocus()
if not self.current_location:
self.date_input.setDate(QDate.currentDate())
self.state_input.clear()
self.county_input.clear()
self.city_input.clear()
self.site_input.clear()
# Don't clear the PDF/PNG checkboxes here - let user maintain their preference
# These will only be cleared after successful saves
def save_specimen(self):
required_map = {
"date": self.date_input,
"state": self.state_input,
"county": self.county_input,
"city": self.city_input,
"site_name": self.site_input,
"species": self.species_input,
"collected_by": self.collected_by_input,
"inat_id": self.inat_input,
"odor": self.odor_input,
"taste": self.taste_input,
}
for field in required_map.values():
field.setStyleSheet("")
for field_key in self.required_fields:
if field_key in required_map:
widget = required_map[field_key]
if not widget.text().strip():
widget.setStyleSheet("border: 1px solid red;")
label_text = field_key.replace("_", " ").title()
self.show_message(f"{label_text} is required.", success=False)
return
elif field_key == "field_photo":
if not (self.photo_yes.isChecked() or self.photo_no.isChecked()):
self.show_message("Field Photo Taken is required.", success=False)
return
elif field_key == "nearby_trees":
if not any(btn.isChecked() for btn in self.trees_group.buttons()):
self.show_message("Nearby Trees selection is required.", success=False)
return
elif field_key == "substrate":
if not any(btn.isChecked() for btn in self.substrate_group.buttons()):
self.show_message("Substrate selection is required.", success=False)
return
elif field_key == "habit":
if not any(btn.isChecked() for btn in self.habit_group.buttons()):
self.show_message("Habit selection is required.", success=False)
return
inat_raw = self.inat_input.text().strip()
if inat_raw and not inat_raw.isdigit():
self.show_message("iNaturalist ID must be a number.", success=False)
return
# Get the prefix from user input, fallback to default if empty
user_prefix = self.prefix_input.text().strip()
if not user_prefix:
user_prefix = self.record_prefix
unique_id = get_next_unique_id(user_prefix)
date = self.current_location.get("date") or self.date_input.date().toString("yyyy-MM-dd")
state = self.current_location.get("state") or self.state_input.text()
county = self.current_location.get("county") or self.county_input.text()
city = self.current_location.get("city") or self.city_input.text()
site_name = self.current_location.get("site_name") or self.site_input.text()
photo = "Yes" if self.photo_yes.isChecked() else "No"
tree = next((btn.text() for btn in self.trees_group.buttons() if btn.isChecked()), "")
substrate = next((btn.text() for btn in self.substrate_group.buttons() if btn.isChecked()), "")
habit = next((btn.text() for btn in self.habit_group.buttons() if btn.isChecked()), "")
insert_specimen(
unique_id,
date,
state,
county,
city,
site_name,
self.species_input.text(),
photo,
tree,
substrate,
habit,
self.odor_input.text() or "None",
self.taste_input.text() or "None",
notes=self.notes_input.toPlainText().strip() or "None",
inat_id=inat_raw or "None",
collected_by=self.collected_by_input.text().strip() or "Unknown"
)
full_qr_content = (
f"ID: {unique_id}\n"
f"Date: {date}\n"
f"Location: {city}, {county}, {state}\n"
f"Site: {site_name}\n"
f"Species: {self.species_input.text()}\n"
f"Photo: {photo}\n"
f"Trees: {tree}\n"
f"Substrate: {substrate}\n"
f"Habit: {habit}\n"
f"Odor: {self.odor_input.text() or 'None'}\n"
f"Taste: {self.taste_input.text() or 'None'}\n"
f"Notes: {self.notes_input.toPlainText().strip() or 'None'}\n"
f"iNat ID: {inat_raw or 'None'}\n"
f"Collected by: {self.collected_by_input.text().strip() or 'Unknown'}"
)
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=10, border=2)
qr.add_data(full_qr_content)
qr.make(fit=True)
qr_img = qr.make_image(fill_color='black', back_color='white').resize((600, 600))
if self.png_checkbox.isChecked():
qr_dir = os.path.join(app_root(), "data", "qr_codes")
ensure_dir(qr_dir)
qr_path = os.path.join(qr_dir, f"{unique_id}.png")
qr_img.save(qr_path)
self.show_message(f"Specimen {unique_id} saved.", success=True)
print_label_with_qrcode(
unique_id,
full_qr_content,
make_pdf=self.pdf_checkbox.isChecked(),
make_image=self.png_checkbox.isChecked()
)
self.clear_form()
def save_prefix_config(self):
"""Save the user's prefix preference to the configuration file"""
try:
config_path = os.path.join(app_root(), "validation_config.json")
user_prefix = self.prefix_input.text().strip()
if not user_prefix:
self.show_message("Please enter a prefix before saving.", success=False)
return
# Load existing config or create new one
try:
with open(config_path, "r") as f:
config_data = json.load(f)
except FileNotFoundError:
config_data = {"required_fields": DEFAULT_REQUIRED_FIELDS}
# Update the prefix
config_data["record_prefix"] = user_prefix
# Save the updated config
with open(config_path, "w") as f:
json.dump(config_data, f, indent=2)
# Update the instance variable
self.record_prefix = user_prefix
self.show_message(f"Prefix '{user_prefix}' saved to configuration.", success=True)
except Exception as e:
self.show_message(f"Error saving prefix configuration: {str(e)}", success=False)
def main():
app = QApplication(sys.argv)
app.setApplicationName(" ")
app.setOrganizationName(" ")
# Set application icon for macOS dock
import platform
if platform.system() == "Darwin":
app.setWindowIcon(QIcon(resource_path("mushroom_icon.icns")))
init_db()
# Load appropriate stylesheet based on platform
import platform
stylesheet_file = "styles_macos.qss" if platform.system() == "Darwin" else "styles.qss"
stylesheet_path = resource_path(stylesheet_file)
if(DEBUG):
logger.info(f"[DEBUG] Attempting to load stylesheet: {stylesheet_path}")
try:
with open(stylesheet_path) as f:
app.setStyleSheet(f.read())
if(DEBUG):
logger.info(f"[DEBUG] Successfully loaded stylesheet: {stylesheet_file}")
except FileNotFoundError:
logger.error(f"[DEBUG] Stylesheet not found: {stylesheet_path}")
# Fallback to default stylesheet if platform-specific one not found
try:
fallback_path = resource_path("styles.qss")
with open(fallback_path) as f:
app.setStyleSheet(f.read())
if(DEBUG):
logger.info(f"[DEBUG] Successfully loaded fallback stylesheet: styles.qss")
except FileNotFoundError:
logger.error(f"[DEBUG] Fallback stylesheet not found: {fallback_path}")
except Exception as e:
logger.error(f"[DEBUG] Error loading fallback stylesheet: {e}")
except Exception as e:
logger.error(f"[DEBUG] Error loading stylesheet: {e}")
window = MycoCatalog()
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()