Skip to content

Commit a0201f0

Browse files
committed
#187 Put an icon on the overall application (naff, but better than having the default)
1 parent e0eef6b commit a0201f0

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

src/prototype_ui/main.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import sys
2-
import time
32

43
from PyQt6.QtCore import Qt
54
from PyQt6.QtWidgets import QMainWindow, QApplication, QProgressBar, QFileDialog
@@ -12,6 +11,7 @@
1211
from src.graphics.track_analysis_canvas import TrackAnalysisCanvas
1312
from src.tracks.tracks import get_all_tracks
1413
from src.ui.open_file_dialog import OpenFileDialog
14+
from ui.icons import get_custom_icon
1515

1616

1717
class MainWindow(QMainWindow):
@@ -26,7 +26,8 @@ def __init__(self):
2626

2727
self.setMinimumSize(200, 200)
2828
self.resize(1800, 400)
29-
self.setWindowTitle("Example")
29+
self.setWindowTitle("DeepRacer Guru")
30+
self.setWindowIcon(get_custom_icon("window_icon"))
3031

3132
# Status Bar
3233
self._please_wait = PleaseWait(self.statusBar(), self.set_busy_cursor, self.set_normal_cursor)

src/ui/actions.py

+5-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
11
# v4 UI STATUS - BRAND NEW
22
# ************************
33

4-
import os
5-
6-
from PyQt6.QtGui import QAction, QIcon
4+
from PyQt6.QtGui import QAction
75
from PyQt6.QtWidgets import QStyle
86

9-
10-
ICON_DIRECTORY = os.path.join("../icons")
11-
ICON_FILE_EXTENSION = ".png"
7+
from ui.icons import get_custom_icon
128

139

1410
class Actions:
1511
def __init__(self, style: QStyle):
1612
self._style = style
17-
assert os.path.isdir(ICON_DIRECTORY)
1813

1914
# REAL
2015
self.open_file = QAction("Open")
2116
self.open_file.setShortcut("Ctrl+O")
2217
self.open_file.setStatusTip("Open log file(s)")
23-
self.open_file.setIcon(self.get_custom_icon("open_file"))
18+
self.open_file.setIcon(get_custom_icon("open_file"))
2419

2520
self.file_info = QAction("Info")
2621
self.file_info.setShortcut("Ctrl+I")
2722
self.file_info.setStatusTip("Get information about the currently open log file(s)")
28-
self.file_info.setIcon(self.get_custom_icon("file_info"))
23+
self.file_info.setIcon(get_custom_icon("file_info"))
2924

3025
self.change_log_directory = QAction("Directory")
3126
self.change_log_directory.setShortcut("Ctrl+D")
3227
self.change_log_directory.setStatusTip("Change log file source directory")
33-
self.change_log_directory.setIcon(self.get_custom_icon("change_log_directory"))
28+
self.change_log_directory.setIcon(get_custom_icon("change_log_directory"))
3429

3530
self.set_file_options = QAction("Options")
3631
self.set_file_options.setStatusTip("Set special options for opening log file(s)")
@@ -39,11 +34,4 @@ def __init__(self, style: QStyle):
3934
self.exit.setStatusTip("Exit application")
4035

4136
# Example of how to set a standard icon when I need to ....
42-
4337
# self.change_log_directory.setIcon(style.standardIcon(QStyle.StandardPixmap.SP_DirIcon))
44-
45-
@staticmethod
46-
def get_custom_icon(icon_name: str):
47-
file_path = os.path.join(ICON_DIRECTORY, icon_name + ".png")
48-
assert os.path.isfile(file_path)
49-
return QIcon(file_path)

src/ui/icons.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
from PyQt6.QtGui import QIcon
4+
5+
6+
ICON_DIRECTORY = os.path.join("../icons")
7+
ICON_FILE_EXTENSION = ".png"
8+
9+
10+
def get_custom_icon(icon_name: str):
11+
file_path = os.path.join(ICON_DIRECTORY, icon_name + ".png")
12+
assert os.path.isfile(file_path)
13+
return QIcon(file_path)

0 commit comments

Comments
 (0)