From 61f6fb386e162ed2bdbd2f9351e7c220c898483f Mon Sep 17 00:00:00 2001 From: suchinton2001 Date: Thu, 12 Oct 2023 11:04:55 +0530 Subject: agl-demo-control-panel: Add installation steps for debian/RPiOS V1: - Fix window dragging event crash - Update dependencies in requirements.txt - Add installation instructions for Debian-based systems - Update Dashboard scaling of icons SPEC-4929 Signed-off-by: suchinton2001 Change-Id: I200f18606a6008780d2f4553052f24a9df5d10b7 --- Widgets/Dashboard.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'Widgets') diff --git a/Widgets/Dashboard.py b/Widgets/Dashboard.py index 591f296..1d77e53 100644 --- a/Widgets/Dashboard.py +++ b/Widgets/Dashboard.py @@ -19,6 +19,7 @@ import sys from PyQt5 import uic from PyQt5 import QtWidgets from PyQt5.QtCore import pyqtSignal +from PyQt5 import QtCore, QtGui current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -32,6 +33,9 @@ Form, Base = uic.loadUiType(os.path.join(current_dir, "../ui/Dashboard.ui")) # ======================================== +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtCore import pyqtSignal + class Dashboard(Base, Form): """ A class representing the dashboard widget. @@ -41,6 +45,7 @@ class Dashboard(Base, Form): Methods: - __init__(self, parent=None): Initializes the Dashboard widget. + - set_icon(self, tile, size): Sets the icon for the given tile. - tile_clicked(self, tile): Handles the tile click event. """ @@ -62,13 +67,27 @@ class Dashboard(Base, Form): self.DB_HVAC_Tile, self.DB_Steering_Tile, self.DB_Settings_Tile) - + DashboardTiles = QtWidgets.QButtonGroup(self) + + DashboardTiles.buttonClicked.connect(self.tile_clicked) for i, tile in enumerate(Dashboard_tiles): + self.set_icon(tile, 55) DashboardTiles.addButton(tile) - - DashboardTiles.buttonClicked.connect(self.tile_clicked) + + def set_icon(self, tile, size): + """ + Sets the icon for the given tile. + + Parameters: + - tile: The tile for which the icon needs to be set. + - size: The size of the icon. + """ + icon = tile.icon() + scaled_pixmap = icon.pixmap(icon.availableSizes()[0]).scaled(size, size, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + tile.setIcon(QtGui.QIcon(scaled_pixmap)) + tile.setIconSize(QtCore.QSize(size, size)) def tile_clicked(self, tile): """ -- cgit 1.2.3-korg