diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-09 17:09:25 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-09 17:09:25 +0200 |
commit | d5469560cecafb8bf19db18ee930970491798f78 (patch) | |
tree | 4586a5f46b499715a14346ac45d06bd993340aa5 | |
parent | cbd5af58165bb2a05dcb8153804c9a9261be89b9 (diff) |
eindopdracht klaar
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | eindopdracht/applicatie/imgs.base.sql | 2 | ||||
-rwxr-xr-x | eindopdracht/applicatie/main.py | 17 | ||||
-rw-r--r-- | eindopdracht/applicatie/makefile | 32 |
4 files changed, 49 insertions, 5 deletions
@@ -22,6 +22,7 @@ eindopdracht/q5.sql **/*.tex **/*.toc - eindopdracht/applicatie/venv/ eindopdracht/applicatie/__pycache__/ +eindopdracht/applicatie/img/* +eindopdracht/applicatie/imgs.sql diff --git a/eindopdracht/applicatie/imgs.base.sql b/eindopdracht/applicatie/imgs.base.sql new file mode 100644 index 0000000..9936ceb --- /dev/null +++ b/eindopdracht/applicatie/imgs.base.sql @@ -0,0 +1,2 @@ +alter table Merk add column Logo varchar(255) null; + diff --git a/eindopdracht/applicatie/main.py b/eindopdracht/applicatie/main.py index 3327e07..2b6a19a 100755 --- a/eindopdracht/applicatie/main.py +++ b/eindopdracht/applicatie/main.py @@ -5,6 +5,7 @@ import sys import json from mysql.connector import MySQLConnection, Error import mysql.connector +from PyQt6.QtGui import QPixmap from PyQt6.QtWidgets import QApplication, QDialog, QComboBox, QLabel, QPlainTextEdit, QRadioButton, QHBoxLayout, QVBoxLayout db = mysql.connector.connect(host="localhost", user=os.getlogin(), database="mysql") @@ -28,8 +29,10 @@ def get_brand_info(brand): location_country = cursor.fetchone() return_dict["location"] = None if brand == None else location_country[0] return_dict["country"] = None if brand == None else location_country[1] - cursor.execute("select Naam from Merk where ID = %s", (brand,)) - return_dict["name"] = None if brand == None else cursor.fetchone()[0] + cursor.execute("select Naam, Logo from Merk where ID = %s", (brand,)) + name_logo_results = cursor.fetchone() + return_dict["name"] = None if brand == None else name_logo_results[0] + return_dict["logo_image_path"] = None if brand == None else name_logo_results[1] return return_dict def get_model_info(model): @@ -89,11 +92,15 @@ class MainWindow(QDialog): select_layout.addWidget(model_facts_label) select_layout.addWidget(self.model_facts) - viewer_layout = QVBoxLayout() + self.viewer_widget = QLabel() + self.viewer_widget.setScaledContents(True) + self.viewer_widget.setMinimumHeight(100) + self.viewer_widget.setMinimumWidth(100) layout = QHBoxLayout() layout.addLayout(select_layout) - layout.addLayout(viewer_layout) + layout.addWidget(self.viewer_widget) + layout.setStretch(0, 1) layout.setStretch(1, 2) self.brand_dropdown.clear() @@ -109,6 +116,8 @@ class MainWindow(QDialog): self.model_info = get_model_info(self.model) self.model_facts.setPlainText(self.get_model_info_human_readable()) + self.viewer_widget.setPixmap(QPixmap(self.brand_info["logo_image_path"])) + def switch_brand(self, index): self.brand = self.brand_dropdown.itemData(index) self.update() diff --git a/eindopdracht/applicatie/makefile b/eindopdracht/applicatie/makefile new file mode 100644 index 0000000..28c7697 --- /dev/null +++ b/eindopdracht/applicatie/makefile @@ -0,0 +1,32 @@ +IMGS += img/aston-martin.png \ + img/audi.png \ + img/bmw.png \ + img/cadillac.png \ + img/chevrolet.png \ + img/dodge.png \ + img/fiat.png \ + img/ford.png \ + img/lamborghini.png \ + img/lexus.png \ + img/lotus.png \ + img/mazda.png \ + img/mercedes-benz.png \ + img/mitsubishi.png \ + img/pontiac.png \ + img/porsche.png \ + img/renault.png \ + img/subaru.png \ + img/toyota.png \ + img/vauxhall.png \ + img/volkswagen.png + +IMGS_SQL = $(patsubst %.png,%.sql, $(IMGS)) + +%.sql: %.png + echo "update Merk set Logo = '$(abspath $<)' where concat(replace(lower(Naam), ' ', '-'), '.png') = '$(shell basename $<)';" > $@ + +imgs.sql: imgs.base.sql $(IMGS_SQL) + cat imgs.base.sql $(IMGS_SQL) > $@ + +clean:: + rm $(IMGS_SQL) imgs.sql |