From 5a91ec638eeef1d9c9f0de9d78b04cd772b78a4e Mon Sep 17 00:00:00 2001 From: VanillaHellen Date: Mon, 1 Feb 2021 17:30:30 +0100 Subject: [PATCH 1/2] added homepage --- win_venv/main.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/win_venv/main.py b/win_venv/main.py index 92e379c..5cc1651 100644 --- a/win_venv/main.py +++ b/win_venv/main.py @@ -6,7 +6,7 @@ from datetime import datetime import time from PyQt5 import QtCore from PyQt5.QtWidgets import * -from PyQt5.QtGui import QIcon, QPixmap, QMovie +from PyQt5.QtGui import * from PyQt5.QtCore import * scriptPath = os.path.dirname(os.path.realpath(__file__)) @@ -17,6 +17,13 @@ LIB_RAW = 0 LIB_VIS = 1 +stylesheet = """ + MainWindow { + background: qlineargradient(x1:0 y1:0, x2:1 y2:0, stop:0 rgba(255,218,113,1), stop:0.5 rgba(215,137,255,1), stop:1 rgba(105,126,255,1)); + } +""" + + def files(path): for subdir, dirs, files_list in os.walk(path): for file in files_list: @@ -221,7 +228,35 @@ class MainWindow(QMainWindow): self.setWindowTitle('VisionScore') scriptDir = os.path.dirname(os.path.realpath(__file__)) self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg')) - + + # Background gradient + p = QPalette() + gradient = QLinearGradient(0, 0, 0, 1000) + gradient.setColorAt(0.0, QColor(105, 126, 255)) + gradient.setColorAt(0.4, QColor(215, 137, 255)) + gradient.setColorAt(1.0, QColor(255, 204, 120)) + p.setBrush(QPalette.Window, QBrush(gradient)) + self.setPalette(p) + + # Upload file button + instructions on homepage + label = QLabel('Welcome to VisionScore! Use the button below to upload a file and start analyzing it. If you need further help, please click the "help" item in the menu above.', self) + label.setFont(QFont('Arial', 14)) + label.setStyleSheet('color: white;') + label.adjustSize() + label.move(200,200) + + shadow = QGraphicsDropShadowEffect() + shadow.setBlurRadius(10) + shadow.setOffset(2) + label.setGraphicsEffect(shadow) + + button = QPushButton('Upload file', self) + button.setToolTip('This is an example button') + button.move(850,270) + button.setFixedSize(220, 50) + button.clicked.connect(self.showUploadFile) + + # File menu menuBar = self.menuBar() fileMenu = QMenu("&File", self) @@ -263,6 +298,7 @@ class MainWindow(QMainWindow): def main(): app = QApplication(sys.argv) + app.setStyleSheet(stylesheet) w = MainWindow() sys.exit(app.exec_()) From 17194ad19b80f048722685670d182ab02d7505e8 Mon Sep 17 00:00:00 2001 From: VanillaHellen Date: Mon, 1 Feb 2021 17:35:26 +0100 Subject: [PATCH 2/2] help fix --- win_venv/main.py | 50 ++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/win_venv/main.py b/win_venv/main.py index 5cc1651..bc22af5 100644 --- a/win_venv/main.py +++ b/win_venv/main.py @@ -182,7 +182,7 @@ class formatHelp(QLabel): with open(scriptPath + os.path.sep + 'static/help.txt', 'r', encoding='utf-8') as file: help_text = file.read().replace('\n', '') self.setText(help_text) - self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px;") + self.setStyleSheet("padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; font-size:32px; background-color: white;") self.adjustSize() @@ -198,6 +198,25 @@ class MainWindow(QMainWindow): def showHelp(self): label = formatHelp() self.setCentralWidget(label) + + def showHomepage(self): + # Upload file button + instructions on homepage + label = QLabel('Welcome to VisionScore! Use the button below to upload a file and start analyzing it. If you need further help, please click the "help" item in the menu above.', self) + label.setFont(QFont('Arial', 14)) + label.setStyleSheet('color: white;') + label.adjustSize() + label.move(200,200) + + shadow = QGraphicsDropShadowEffect() + shadow.setBlurRadius(10) + shadow.setOffset(2) + label.setGraphicsEffect(shadow) + + button = QPushButton('Upload file', self) + button.setToolTip('This is an example button') + button.move(850,270) + button.setFixedSize(220, 50) + button.clicked.connect(self.showUploadFile) # Show raw uploaded files def showInputLibrary(self): @@ -228,34 +247,7 @@ class MainWindow(QMainWindow): self.setWindowTitle('VisionScore') scriptDir = os.path.dirname(os.path.realpath(__file__)) self.setWindowIcon(QIcon(scriptDir + os.path.sep + 'static/v_logo.jpg')) - - # Background gradient - p = QPalette() - gradient = QLinearGradient(0, 0, 0, 1000) - gradient.setColorAt(0.0, QColor(105, 126, 255)) - gradient.setColorAt(0.4, QColor(215, 137, 255)) - gradient.setColorAt(1.0, QColor(255, 204, 120)) - p.setBrush(QPalette.Window, QBrush(gradient)) - self.setPalette(p) - - # Upload file button + instructions on homepage - label = QLabel('Welcome to VisionScore! Use the button below to upload a file and start analyzing it. If you need further help, please click the "help" item in the menu above.', self) - label.setFont(QFont('Arial', 14)) - label.setStyleSheet('color: white;') - label.adjustSize() - label.move(200,200) - - shadow = QGraphicsDropShadowEffect() - shadow.setBlurRadius(10) - shadow.setOffset(2) - label.setGraphicsEffect(shadow) - - button = QPushButton('Upload file', self) - button.setToolTip('This is an example button') - button.move(850,270) - button.setFixedSize(220, 50) - button.clicked.connect(self.showUploadFile) - + self.showHomepage() # File menu menuBar = self.menuBar()