-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscsi_main_window.py
582 lines (478 loc) · 24 KB
/
scsi_main_window.py
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
import sys
import json
import ctypes
from PyQt6.QtWidgets import QApplication, QMenu, QToolTip, QRadioButton, QLabel, QVBoxLayout, QPushButton, QWidget, QListWidget, QHBoxLayout, QLineEdit, QGroupBox, QGridLayout, QListWidgetItem, QSizePolicy
from PyQt6.QtGui import QMovie, QIcon, QFont, QPixmap, QFontMetrics, QKeySequence
from PyQt6.QtCore import Qt, QThread, pyqtSignal
from scsi_ocr_scanner import capture_screen, process_image
from scsi_utils import get_region_size, load_rectangle_bounds, clean_input_text, find_matching_headers, results_to_widget, get_widget_item, assign_icon, resource_path, get_user_directory
from scsi_search_area_overlay import OverlayRectangle
__application_name__ = "Radar Scan ID"
__copyright__ = "© 2025 GoatCliffs. All rights reserved."
__version__ = "0.8.1"
GROUND_MINERALS_TABLE_NAME = "GROUND_MINERALS"
ASTEROIDS_TABLE_NAME = "ASTEROID_TYPES"
DATABASE_FILE = "resources\\scsi_database.db"
HISTORY_FILE = "data\\scan_history.json"
SCREENSHOT_PATH = "data\\screenshot.png"
WINDOW_ICON = "resources/scsi_tool.ico"
SCAN_AREA_ACTIVE_ICON = "resources/area_settings_active_icon_128.png"
SCAN_AREA_ICON = "resources/area_settings_icon_128.png"
FRED_STATUS = "resources/fred-fred-mopping_200.gif"
READY_STATUS = "resources/ready_to_scan_200.gif"
SCANNING_STATUS = "resources/scanning_200.gif"
class ScanWorker(QThread):
# Define custom signals for passing results back to the UI
scan_finished = pyqtSignal(str, list)
def __init__(self, region, screenshot_path, input_textbox,
scanner_used, options_radio_button_ground_mining):
super().__init__()
self.region = region
self.screenshot_path = screenshot_path
self.input_textbox = input_textbox
self.scanner_used = scanner_used
self.options_radio_button_ground_mining = options_radio_button_ground_mining
# Load the rectangle bounds from the saved file
self.region = load_rectangle_bounds()
if not self.region:
# Fallback to a default region if no saved bounds exist
self.region = (0, 0, 800, 600)
print("Using Fallback Bounds")
def run(self):
if self.scanner_used:
captured_path = capture_screen(self.region, self.screenshot_path)
scanned_text = process_image(captured_path)
else:
scanned_text = self.input_textbox.text()
#Clean text from anything but numbers
scanned_text = clean_input_text(scanned_text)
#SET THE TABLE TO USE BASED ON A TOGGLE ON THE UI
if self.options_radio_button_ground_mining.isChecked():
TABLE_NAME = GROUND_MINERALS_TABLE_NAME
else:
TABLE_NAME = ASTEROIDS_TABLE_NAME
matches = find_matching_headers(resource_path(DATABASE_FILE), TABLE_NAME, scanned_text)
# Emit the results when finished
self.scan_finished.emit(scanned_text, matches)
class ScanWindow(QWidget):
def __init__(self):
super().__init__()
# Screen region settings
self.region = get_region_size() # Adjust the region size
self.screenshot_path = get_user_directory(SCREENSHOT_PATH)
# History
self.history = []
# Worker thread
self.worker = None
# Rectangle overlay instance (initially None)
self.overlay_rectangle = None
# Initialize the window
self.init_ui()
self.load_history()
self.update_status_image("fred")
self.history_list.scrollToBottom()
def init_ui(self):
# Set up the window
self.setWindowTitle(__application_name__)
self.setWindowIcon(QIcon(resource_path(WINDOW_ICON)))
#self.setGeometry(100, 100, 800, 500) # Window size
self.setFixedSize(800, 540) # Fixed size window
#Dark Top Window Bar
hwnd = int(self.winId())
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
ctypes.windll.dwmapi.DwmSetWindowAttribute(
hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, ctypes.byref(ctypes.c_int(1)), ctypes.sizeof(ctypes.c_int)
)
# Style Sheet for all the Group Boxes
#group_box_style_sheet = "QGroupBox { font-size: 14px; color: #74006a; }"
# Center the window
screen = QApplication.primaryScreen().geometry()
x = (screen.width() - self.width()) // 2
y = (screen.height() - self.height()) // 2
self.move(x, y)
#Used for determining status image changes
self.scanner_used = False
self.status_image_state = None
# OPTIONS SECTION
options_groupbox = QGroupBox("Options", self)
options_groupbox.setStyleSheet("QGroupBox {font-size: 14px;}")
options_layout = QVBoxLayout()
options_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.options_radio_button_ground_mining = QRadioButton("Ground Mining")
self.options_radio_button_ground_mining.setChecked(True)
self.options_radio_button_asteroid_mining = QRadioButton("Asteroid Mining / Salvaging")
self.options_radio_button_asteroid_mining.clicked.connect(self.update_results_key)
self.options_radio_button_ground_mining.clicked.connect(self.update_results_key)
options_layout.addWidget(self.options_radio_button_ground_mining)
options_layout.addWidget(self.options_radio_button_asteroid_mining)
options_groupbox.setLayout(options_layout)
# INPUT SECTION
input_groupbox = QGroupBox("Search", self)
input_groupbox.setStyleSheet("QGroupBox {font-size: 14px; }")
input_layout = QVBoxLayout()
# Input Text Box Label
input_title_label = QLabel("Radar Signature", self)
input_title_label.setAlignment(Qt.AlignmentFlag.AlignLeft)
input_title_label.setStyleSheet("font-size: 16px; padding: 10px;")
# Input Text Box
self.input_textbox = QLineEdit(self)
self.input_textbox.setPlaceholderText("Example: 7200")
self.input_textbox.setStyleSheet("font-size: 16px; padding: 10px; color: #37AEFE")
self.input_textbox.setAlignment(Qt.AlignmentFlag.AlignLeft)
self.input_textbox.returnPressed.connect(self.start_search)
self.input_textbox.textChanged.connect(self.on_text_changed)
# Input Search Button
self.input_search_button = QPushButton("Search", self)
self.input_search_button.setToolTip("Searches database for search box entry.")
self.input_search_button.clicked.connect(self.start_search)
self.input_search_button.setEnabled(False)
# Input Section Layout
input_section_layout = QHBoxLayout()
input_section_layout.addWidget(input_title_label)
input_section_layout.addWidget(self.input_textbox)
input_layout.addLayout(input_section_layout)
input_layout.addWidget(self.input_search_button)
input_groupbox.setLayout(input_layout)
# SCAN SECTION
scan_groupbox = QGroupBox("Scan Area of Screen", self)
scan_groupbox.setStyleSheet("QGroupBox { font-size: 14px; }")
scan_section_layout = QVBoxLayout()
self.toggle_scan_area_button = QPushButton("", self)
self.toggle_scan_area_button.setFixedWidth(25)
self.toggle_scan_area_button.setStyleSheet("QPushButton { background-color: transparent; border: none;}")
self.toggle_scan_area_button.setIcon(QIcon(resource_path(SCAN_AREA_ICON)))
self.toggle_scan_area_button.setToolTip("Move, or resize scan area.")
self.toggle_scan_area_button.setCheckable(True)
self.toggle_scan_area_button.clicked.connect(self.toggle_scan_area)
toggle_scan_area_button_wrapper = QHBoxLayout()
toggle_scan_area_button_wrapper.setAlignment(Qt.AlignmentFlag.AlignRight)
toggle_scan_area_button_wrapper.addWidget(self.toggle_scan_area_button)
self.scan_button = QPushButton("Scan Screen", self)
self.scan_button.setToolTip("Searches database with number found in a defined area of the screen.")
#self.scan_button.setShortcut(tr()) #TODO
self.scan_button.clicked.connect(self.start_scan)
self.status_image_wrapper = QVBoxLayout() #Need it so the image is centered
self.status_image_wrapper.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.status_image_label = QLabel(self)
self.status_image_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.status_image_label.setFixedSize(200, 200) # Set fixed size for the image
self.status_image_wrapper.addWidget(self.status_image_label)
scan_section_layout.addLayout(toggle_scan_area_button_wrapper)
scan_section_layout.addLayout(self.status_image_wrapper)
scan_section_layout.addWidget(self.scan_button)
scan_groupbox.setLayout(scan_section_layout)
# RESULT SECTION
result_groupbox = QGroupBox("Results", self)
result_groupbox.setStyleSheet("QGroupBox { font-size: 14px; }")
self.result_layout = QVBoxLayout()
#self.results_widget = QLabel("Ready to go")
#self.results_widget.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.setup_asteroid_results_view()
self.setup_ground_results_view()
#self.result_layout.addWidget(self.results_widget)
result_groupbox.setLayout(self.result_layout)
# HISTORY SECTION
#history_groupbox = QGroupBox("History", self)
#history_groupbox.setMaximumWidth(400)
#history_groupbox.setMinimumWidth(400)
#history_groupbox.setStyleSheet("QGroupBox { font-size: 14px; }")
history_layout = QVBoxLayout()
# History Label
history_label = QLabel("")
history_label.setAlignment(Qt.AlignmentFlag.AlignLeft)
# History Clear Button
history_clear_button = QPushButton("Clear History", self)
history_clear_button.clicked.connect(self.clear_history)
#History Label and Scan Area Button Layout
history_top_section_layout = QHBoxLayout()
#history_top_section_layout.addStretch()
history_top_section_layout.addWidget(history_label)
history_top_section_layout.addWidget(history_clear_button)
# History List
self.history_list = QListWidget(self)
self.history_list.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.history_list.customContextMenuRequested.connect(self.show_history_context_menu)
self.history_list.setMaximumWidth(400)
self.history_list.setStyleSheet("""
QListWidget::item {
background-color: #455364;
}
QListWidget::item:hover {
background-color: #19232D;
}
QListWidget::item:selected {
background-color: #37AEFE;
}
""")
##455364#00afaf#00ffff
history_layout.addLayout(history_top_section_layout)
history_layout.addWidget(self.history_list)
self.result_layout.addLayout(history_layout)
# Version Label
version_label = QLabel(__application_name__ + " " + __version__)
version_label.setToolTip(__copyright__)
version_label.setStyleSheet("""
QLabel {
color: #54687A;
}
QLabel:hover {
color: #37AEFE;
}
""")
version_layout = QHBoxLayout()
version_layout.addStretch()
version_layout.addWidget(version_label)
# Grid Layout
grid_layout = QGridLayout()
scan_groupbox.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
# Add all sections to the grid layout
grid_layout.addWidget(options_groupbox, 0, 0, 1, 1)
grid_layout.addWidget(input_groupbox, 1, 0, 1, 1)
grid_layout.addWidget(scan_groupbox, 2, 0, 1, 1)
grid_layout.addWidget(result_groupbox, 0, 1, 3, 1)
grid_layout.addLayout(version_layout, 3, 1, 1, 1 )
#grid_layout.addWidget(history_groupbox, 2, 1, 1, 1)
self.setLayout(grid_layout)
def show_history_context_menu(self, position):
item = self.history_list.itemAt(position)
if item is None:
return
# Create Menu
menu = QMenu(self)
copy_action = menu.addAction("Copy")
# Exec menu, and get the selected action
action = menu.exec(self.history_list.mapToGlobal(position))
# Perform actions based on selected menu option
if action == copy_action:
self.copy_history_item_to_clipboard(item)
def copy_history_item_to_clipboard(self, item):
clipboard = QApplication.clipboard()
clipboard.setText(item.item_text)
def keyPressEvent(self, event):
if event.matches(QKeySequence.StandardKey.Copy):
self.copy_history_selected_item()
else:
super().keyPressEvent(event)
def copy_history_selected_item(self):
selected_item = self.history_list.currentItem()
if selected_item is not None:
clipboard = QApplication.clipboard()
clipboard.setText(selected_item.item_text)
def on_text_changed(self, text):
'''Turns off the Search Button when there is no text in the search box'''
if text:
self.input_search_button.setEnabled(True)
else:
self.input_search_button.setEnabled(False)
def start_search(self):
if self.input_search_button.isEnabled() == True:
self.input_search_button.setEnabled(False)
self.input_search_button.setText("Searching...")
self.scan_button.setEnabled(False)
self.scanner_used = False
else:
return
#starts cleaning when the scanner isn't being used
self.update_status_image("fred")
self.start_scan_worker()
def toggle_scan_area(self):
if self.overlay_rectangle is None:
# Define the rectangle position and size
region = get_region_size()
loc_x, loc_y, width, height = region[0],region[1],region[2],region[3]
# Create and show the rectangle
self.overlay_rectangle = OverlayRectangle( loc_x, loc_y, width, height )
self.overlay_rectangle.show()
self.toggle_scan_area_button.setIcon(QIcon(resource_path(SCAN_AREA_ACTIVE_ICON)))
else:
# If the rectangle already exists, toggle it off
self.overlay_rectangle.close()
self.overlay_rectangle = None
self.toggle_scan_area_button.setIcon(QIcon(resource_path(SCAN_AREA_ICON)))
def start_scan(self):
# Disable the scan buttons during the scan
self.scan_button.setText("Scanning...")
self.scan_button.setEnabled(False)
self.input_search_button.setEnabled(False)
self.update_status_image("scanning")
self.scanner_used = True
self.start_scan_worker()
def start_scan_worker(self):
# Create and start the worker thread
self.worker = ScanWorker(self.region, self.screenshot_path, self.input_textbox,
self.scanner_used, self.options_radio_button_ground_mining)
self.worker.scan_finished.connect(self.handle_scan_finished)
self.worker.finished.connect(self.cleanup_worker) # Clean up when the thread finishes
self.worker.start()
def handle_scan_finished(self, scanned_text, matches):
# Display results
results = results_to_widget(scanned_text, matches)
#self.update_results(results)
# Add to history
self.add_to_history(results)
if self.scanner_used:
# Update the status to "ready" only when the scanner was used
self.update_status_image("ready")
# Reenable the input box only if there is text inside
if self.input_textbox.text():
self.input_search_button.setEnabled(True)
self.input_search_button.setText("Search")
# Re-enable the scan button
self.scan_button.setEnabled(True)
self.scan_button.setText("Scan Screen")
def cleanup_worker(self):
"""Clean up the worker thread after it finishes."""
if self.worker:
self.worker.quit() # Signal the thread to stop
self.worker.wait() # Wait for it to finish
self.worker = None # Clear the reference to the thread
def add_to_history(self, results):
# Create entry
entry = {
"time": results["time"],
"scanned_text": results["scanned_text"],
"matches": results["matches"],
}
# Update history
self.history.append(entry)
# Need to create a QListWidgetItem before making it into a custom results widget
list_widget_item = QListWidgetItem()
list_widget_item.setSizeHint(results["widget_item"].sizeHint())
self.history_list.addItem(list_widget_item)
self.history_list.setItemWidget(list_widget_item, results["widget_item"])
list_widget_item.setSelected(True)
list_widget_item.item_text = results["widget_item"].item_text
self.history_list.scrollToBottom()
# Save history to file
self.save_history()
def load_history(self):
try:
with open(get_user_directory(HISTORY_FILE), "r") as file:
self.history = json.load(file)
for entry in self.history:
time = entry["time"]
scanned_text = entry["scanned_text"]
matches = entry["matches"]
# Need to create a QListWidgetItem before making it into a custom results widget
list_widget_item = QListWidgetItem()
results_widget = get_widget_item(time, scanned_text, matches)
list_widget_item.setSizeHint(results_widget.sizeHint())
self.history_list.addItem(list_widget_item)
self.history_list.setItemWidget(list_widget_item, results_widget)
list_widget_item.item_text = results_widget.item_text
except FileNotFoundError:
# No history file exists yet
self.history = []
with open(get_user_directory(HISTORY_FILE), "w") as file:
json.dump(self.history, file)
def save_history(self):
with open(get_user_directory(HISTORY_FILE), "w") as file:
json.dump(self.history, file, indent=4)
def clear_history(self):
self.history = []
with open(get_user_directory(HISTORY_FILE), "w") as file:
json.dump(self.history, file)
self.history_list.clear()
def copy_history_item(self, item):
#self.history_list.clicked.connect(self.copy_history_item(self.history_list.currentItem()))
clipboard = app.clipboard()
clipboard.setText(str(item))
def update_status_image(self, state):
"""
Update the status image based on the current state.
:param state: "fred", "ready", "scanning"
"""
gif_paths = {
"fred": resource_path(FRED_STATUS),
"ready": resource_path(READY_STATUS),
"scanning": resource_path(SCANNING_STATUS),
}
if self.status_image_state != state:
self.status_image_state = state
else:
return
#print("B "+ state)
if state in gif_paths:
gif_path = gif_paths[state]
self.movie = QMovie(gif_path)
self.status_image_label.setMovie(self.movie)
self.movie.start()
#print("A "+ self.movie.fileName())
def setup_ground_results_view(self):
# Gems Key Label
gems_label_text = "Gems means any of them."
self.gems_label = QLabel(gems_label_text)
self.gems_label.setToolTip("Gems share their Radio Signature.")
self.gems_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.gems_label.setFixedWidth(QFontMetrics(self.gems_label.font()).horizontalAdvance(gems_label_text) + 15)
self.gems_label.setWordWrap(True)
self.gems_label.setStyleSheet("color: #3ec500; font-weight: bold; font-style:italic;")
# Icons Labels
aph_icon_path = assign_icon("Aphorite")
self.aph_icon_label = QLabel()
self.aph_icon_label.setToolTip("Aphorite")
self.aph_icon_label.setFixedWidth(24)
self.aph_icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.aph_icon_label.setPixmap(QPixmap(aph_icon_path).scaled(16, 16)) # Adjust size as needed
dol_icon_path = assign_icon("Dolivine")
self.dol_icon_label = QLabel()
self.dol_icon_label.setToolTip("Dolivine")
self.dol_icon_label.setFixedWidth(24)
self.dol_icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.dol_icon_label.setPixmap(QPixmap(dol_icon_path).scaled(16, 16)) # Adjust size as needed
had_icon_path = assign_icon("Hadanite")
self.had_icon_label = QLabel()
self.had_icon_label.setToolTip("Hadanite")
self.had_icon_label.setFixedWidth(24)
self.had_icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.had_icon_label.setPixmap(QPixmap(had_icon_path).scaled(16, 16)) # Adjust size as needed
jal_icon_path = assign_icon("Janalite")
self.jal_icon_label = QLabel()
self.jal_icon_label.setToolTip("Janalite")
self.jal_icon_label.setFixedWidth(24)
self.jal_icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.jal_icon_label.setPixmap(QPixmap(jal_icon_path).scaled(16, 16)) # Adjust size as needed
self.gems_h_layout_1 = QHBoxLayout()
self.gems_h_layout_1.addWidget(self.aph_icon_label)
self.gems_h_layout_1.addWidget(self.dol_icon_label)
self.gems_h_layout_1.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.gems_h_layout_2 = QHBoxLayout()
self.gems_h_layout_2.addWidget(self.had_icon_label)
self.gems_h_layout_2.addWidget(self.jal_icon_label)
self.gems_h_layout_2.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.gems_v_layout = QVBoxLayout()
self.gems_v_layout.addLayout(self.gems_h_layout_1)
self.gems_v_layout.addLayout(self.gems_h_layout_2)
self.gems_v_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.ground_results_key_layout = QHBoxLayout()
self.ground_results_key_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.ground_results_key_layout.setContentsMargins(1, 1, 1, 1)
self.ground_results_key_layout.setSpacing(1)#for debugging set to 1
self.ground_results_key_layout.addWidget(self.gems_label)
self.ground_results_key_layout.addLayout(self.gems_v_layout)
# Groupbox
self.ground_results_key_groupbox = QGroupBox("", self)
self.ground_results_key_groupbox.setStyleSheet("QGroupBox { font-size: 14px; }")
self.ground_results_key_groupbox.setLayout(self.ground_results_key_layout)
self.result_layout.addWidget(self.ground_results_key_groupbox)
def setup_asteroid_results_view(self):
print("Setup Asteroid Results")
def update_results_key(self):
if self.options_radio_button_ground_mining.isChecked():
self.ground_results_key_groupbox.show()
elif self.options_radio_button_asteroid_mining.isChecked():
self.ground_results_key_groupbox.hide()
#def update_results(self, results):
#if self.results_widget:
# self.results_widget.deleteLater()
# self.results_widget = None
#self.results_widget = get_widget_item(results["time"], results["scanned_text"], results["matches"])
#self.result_layout.addWidget(self.results_widget)
import qdarkstyle
# Main entry point
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt6'))
window = ScanWindow()
window.show()
sys.exit(app.exec())