Fix bug in download_window.py. Set fixed aspect ratio for forecast images.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,9 +5,7 @@ wav_converter.py
|
||||
to_do.txt
|
||||
csv_info.txt
|
||||
pyinstaller_cmd.txt
|
||||
icons_imgs
|
||||
TestData
|
||||
themes/.current_theme
|
||||
*.bat
|
||||
*.sh
|
||||
splash.jpg
|
||||
.vscode/
|
||||
|
||||
59
artemis.py
59
artemis.py
@@ -1,7 +1,6 @@
|
||||
from collections import namedtuple
|
||||
from itertools import chain
|
||||
from functools import partial
|
||||
from glob import glob
|
||||
import webbrowser
|
||||
import os
|
||||
import sys
|
||||
@@ -15,7 +14,6 @@ from PyQt5.QtWidgets import (QMainWindow,
|
||||
QListWidgetItem,
|
||||
QMessageBox,
|
||||
QSplashScreen,
|
||||
QTreeView,
|
||||
QTreeWidgetItem,)
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5 import uic
|
||||
@@ -25,7 +23,6 @@ from PyQt5.QtCore import (QFileInfo,
|
||||
|
||||
from audio_player import AudioPlayer
|
||||
from space_weather_data import SpaceWeatherData
|
||||
from double_text_button import DoubleTextButton
|
||||
from download_window import DownloadWindow
|
||||
from switchable_label import SwitchableLabelsIterable
|
||||
from constants import (Constants,
|
||||
@@ -44,11 +41,10 @@ from utilities import (checksum_ok,
|
||||
filters_ok,
|
||||
is_undef_freq,
|
||||
is_undef_band,
|
||||
change_unit,
|
||||
format_numbers,
|
||||
resource_path,)
|
||||
|
||||
import icon_rc
|
||||
# import icon_rc
|
||||
|
||||
qt_creator_file = resource_path("artemis.ui")
|
||||
Ui_MainWindow, _ = uic.loadUiType(qt_creator_file)
|
||||
@@ -60,6 +56,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
self.setupUi(self)
|
||||
self.set_initial_size()
|
||||
self.download_window = DownloadWindow()
|
||||
self.download_window.complete.connect(self.show_downloaded_signals)
|
||||
self.actionExit.triggered.connect(qApp.quit)
|
||||
self.action_update_database.triggered.connect(self.ask_if_download)
|
||||
self.action_check_db_ver.triggered.connect(self.check_db_ver)
|
||||
@@ -456,11 +453,21 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
chain(k_storms_colors, a_storm_colors)):
|
||||
lab.set_colors(None, None)
|
||||
|
||||
self.forecast_labels = (self.forecast_lbl_0,
|
||||
self.forecast_lbl_1,
|
||||
self.forecast_lbl_2,
|
||||
self.forecast_lbl_3,
|
||||
self.forecast_lbl_4,
|
||||
self.forecast_lbl_5,
|
||||
self.forecast_lbl_6,
|
||||
self.forecast_lbl_7,
|
||||
self.forecast_lbl_8)
|
||||
self.forecast_label_container.labels = self.forecast_labels
|
||||
|
||||
# Final operations.
|
||||
self.theme.initialize()
|
||||
self.load_db()
|
||||
self.display_signals()
|
||||
self.show()
|
||||
|
||||
@pyqtSlot()
|
||||
def start_update_space_weather(self):
|
||||
@@ -610,20 +617,11 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
val = int([x[4] for x in self.space_weather_data.sgas if "SSN" in x][0])
|
||||
self.sn_lbl.setText(f"{val:d}")
|
||||
|
||||
forecast_labels = (self.forecast_lbl_0,
|
||||
self.forecast_lbl_1,
|
||||
self.forecast_lbl_2,
|
||||
self.forecast_lbl_3,
|
||||
self.forecast_lbl_4,
|
||||
self.forecast_lbl_5,
|
||||
self.forecast_lbl_6,
|
||||
self.forecast_lbl_7,
|
||||
self.forecast_lbl_8)
|
||||
for label, pixmap in zip(forecast_labels, self.space_weather_data.images):
|
||||
for label, pixmap in zip(self.forecast_labels, self.space_weather_data.images):
|
||||
label.setText('')
|
||||
label.setPixmap(pixmap)
|
||||
label.setScaledContents(True)
|
||||
|
||||
label.pixmap = pixmap
|
||||
label.setPixmap(pixmap.scaled(label.size(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
|
||||
label.setStyleSheet("background-color: transparent;")
|
||||
else:
|
||||
pop_up(self, title = Messages.BAD_DOWNLOAD,
|
||||
text = Messages.BAD_DOWNLOAD_MSG).show()
|
||||
@@ -687,10 +685,8 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
item.child(i).setSelected(True)
|
||||
|
||||
def set_initial_size(self):
|
||||
"""
|
||||
Function to handle high resolution screens. The function sets bigger sizes
|
||||
for all the relevant fixed-size widgets.
|
||||
"""
|
||||
"""Function to handle high resolution screens. The function sets bigger sizes
|
||||
for all the relevant fixed-size widgets."""
|
||||
d = QDesktopWidget().availableGeometry()
|
||||
w = d.width()
|
||||
h = d.height()
|
||||
@@ -738,7 +734,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
@pyqtSlot()
|
||||
def download_db(self):
|
||||
if not self.download_window.isVisible():
|
||||
self.download_window.download_thread.finished.connect(self.show_downloaded_signals)
|
||||
self.download_window.download_thread.start()
|
||||
self.download_window.show()
|
||||
|
||||
@@ -782,6 +777,8 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
text = Messages.NO_DB_AVAIL,
|
||||
informative_text = Messages.DOWNLOAD_NOW_QUESTION,
|
||||
is_question = True).exec()
|
||||
if answer == QMessageBox.Yes:
|
||||
self.download_db()
|
||||
else:
|
||||
try:
|
||||
is_checksum_ok = checksum_ok(db, ChecksumWhat.DB)
|
||||
@@ -792,7 +789,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
if is_checksum_ok:
|
||||
pop_up(self, title = Messages.DB_UP_TO_DATE,
|
||||
text = Messages.DB_UP_TO_DATE_MSG).show()
|
||||
|
||||
else:
|
||||
answer = pop_up(self, title = Messages.DB_NEW_VER,
|
||||
text = Messages.DB_NEW_VER_MSG,
|
||||
@@ -803,7 +799,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
|
||||
@pyqtSlot()
|
||||
def show_downloaded_signals(self):
|
||||
if self.download_window.everything_ok:
|
||||
self.search_bar.setEnabled(True)
|
||||
self.load_db()
|
||||
self.display_signals()
|
||||
@@ -831,7 +826,9 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
self.db.fillna(Constants.UNKNOWN, inplace = True)
|
||||
self.db[Signal.WIKI_CLICKED] = False
|
||||
self.update_status_tip(self.total_signals)
|
||||
self.result_list.clear()
|
||||
self.result_list.addItems(self.signal_names)
|
||||
self.result_list.setCurrentItem(None)
|
||||
|
||||
@pyqtSlot()
|
||||
def set_min_value_upper_limit(self, lower_combo_box,
|
||||
@@ -845,7 +842,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
lower_units = lower_combo_box.currentText()
|
||||
upper_units = upper_combo_box.currentText()
|
||||
lower_value = lower_spin_box.value()
|
||||
upper_value = upper_spin_box.value()
|
||||
inf_limit = (lower_value * Constants.CONVERSION_FACTORS[lower_units]) \
|
||||
// Constants.CONVERSION_FACTORS[upper_units]
|
||||
counter = 0
|
||||
@@ -949,7 +945,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
self.result_list.item(index).setHidden(True)
|
||||
# Remove selected item.
|
||||
self.result_list.selectionModel().clear()
|
||||
self.result_list.setCurrentItem(None)
|
||||
self.update_status_tip(available_signals)
|
||||
|
||||
def update_status_tip(self, available_signals):
|
||||
@@ -1123,7 +1119,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
selected_items = [item for item in self.mode_tree_widget.selectedItems()]
|
||||
selected_items_text = [i.text(0) for i in selected_items]
|
||||
parents = [item for item in selected_items_text if item in Constants.MODES.keys()]
|
||||
children = [item for item in selected_items_text if item not in parents]
|
||||
ok = []
|
||||
for item in selected_items:
|
||||
if item.text(0) in parents:
|
||||
@@ -1288,11 +1283,11 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
||||
|
||||
if __name__ == '__main__':
|
||||
my_app = QApplication(sys.argv)
|
||||
img = QPixmap(":/icons/Artemis3.500px.png")
|
||||
# img = img.scaled(600, 600, aspectRatioMode = Qt.KeepAspectRatio)
|
||||
# img = QPixmap(":/icons/Artemis3.500px.png")
|
||||
# splash = QSplashScreen(img)
|
||||
# splash.show()
|
||||
# sleep(2)
|
||||
w = Artemis()
|
||||
artemis = Artemis()
|
||||
artemis.show()
|
||||
# splash.finish(w)
|
||||
sys.exit(my_app.exec_())
|
||||
|
||||
474
artemis.ui
474
artemis.ui
@@ -6119,7 +6119,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="font">
|
||||
@@ -6144,6 +6144,9 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_23">
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="sizePolicy">
|
||||
@@ -6163,30 +6166,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_0">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="sizePolicy">
|
||||
@@ -6206,30 +6185,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_1">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="sizePolicy">
|
||||
@@ -6249,30 +6204,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="sizePolicy">
|
||||
@@ -6292,30 +6223,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="sizePolicy">
|
||||
@@ -6335,30 +6242,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_28">
|
||||
<property name="sizePolicy">
|
||||
@@ -6378,30 +6261,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="sizePolicy">
|
||||
@@ -6421,7 +6280,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
@@ -6440,31 +6299,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_7">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
@@ -6483,8 +6318,59 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_8">
|
||||
<item row="0" column="1" rowspan="9">
|
||||
<widget class="FixedAspectRatioWidget" name="forecast_label_container" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_0">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
@@ -6507,8 +6393,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="forecast_lbl_6">
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
@@ -6531,6 +6423,189 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_4">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="forecast_lbl_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:#ffffff;
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OFF</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -6587,10 +6662,28 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_41">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_21">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="expected_noise_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -6610,6 +6703,24 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_22">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
@@ -7018,6 +7129,17 @@ QSlider::handle:horizontal {
|
||||
<extends>QProgressBar</extends>
|
||||
<header>clickable_progress_bar.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FixedAspectRatioWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>fixed_aspect_ratio_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>FixedAspectRatioLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>fixed_aspect_ratio_label.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="icon.qrc"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from PyQt5 import uic
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from threads import DownloadThread, ThreadStatus
|
||||
from utilities import pop_up, resource_path
|
||||
@@ -8,6 +8,9 @@ from constants import Messages
|
||||
Ui_Download_window, _ = uic.loadUiType(resource_path("download_db_window.ui"))
|
||||
|
||||
class DownloadWindow(QWidget, Ui_Download_window):
|
||||
|
||||
complete = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setupUi(self)
|
||||
@@ -18,7 +21,6 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
||||
Qt.WindowCloseButtonHint #|
|
||||
# Qt.WindowStaysOnTopHint
|
||||
)
|
||||
self.everything_ok = True
|
||||
|
||||
self.no_internet_msg = pop_up(self, title = Messages.NO_CONNECTION,
|
||||
text = Messages.NO_CONNECTION_MSG,
|
||||
@@ -30,17 +32,8 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
||||
|
||||
self.download_thread = DownloadThread()
|
||||
self.download_thread.finished.connect(self.wait_close)
|
||||
|
||||
self.cancel_btn.clicked.connect(self.terminate_process)
|
||||
|
||||
def show_no_connection_warning(self):
|
||||
self.no_internet_msg.show()
|
||||
self.everything_ok = False
|
||||
|
||||
def show_bad_download_warning(self):
|
||||
self.bad_db_download_msg.show()
|
||||
self.everything_ok = False
|
||||
|
||||
@pyqtSlot()
|
||||
def terminate_process(self):
|
||||
if self.download_thread.isRunning():
|
||||
@@ -51,11 +44,12 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
||||
@pyqtSlot()
|
||||
def wait_close(self):
|
||||
if self.download_thread.status is ThreadStatus.OK:
|
||||
self.complete.emit()
|
||||
self.close()
|
||||
elif self.download_thread.status is ThreadStatus.NO_CONNECTION_ERR:
|
||||
self.show_no_connection_warning()
|
||||
self.no_internet_msg.show()
|
||||
elif self.download_thread.status is ThreadStatus.BAD_DOWNLOAD_ERR:
|
||||
self.show_bad_download_warning()
|
||||
self.bad_db_download_msg.show()
|
||||
else:
|
||||
self.close()
|
||||
|
||||
|
||||
14
fixed_aspect_ratio_label.py
Normal file
14
fixed_aspect_ratio_label.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from PyQt5.QtWidgets import QLabel
|
||||
from PyQt5.QtCore import QSize, Qt
|
||||
|
||||
class FixedAspectRatioLabel(QLabel):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self.pixmap = None
|
||||
|
||||
def rescale(self, w, h):
|
||||
self.resize(QSize(w, h))
|
||||
if self.pixmap:
|
||||
self.setPixmap(
|
||||
self.pixmap.scaled(
|
||||
self.size(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation))
|
||||
19
fixed_aspect_ratio_widget.py
Normal file
19
fixed_aspect_ratio_widget.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
|
||||
class FixedAspectRatioWidget(QWidget):
|
||||
space = 10
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self.labels = []
|
||||
|
||||
def resizeEvent(self, event):
|
||||
h, w = self.height(), self.width()
|
||||
h_lbl = h / 9 - self.space
|
||||
w_lbl = 5 * h_lbl
|
||||
|
||||
if w_lbl > w:
|
||||
w_lbl = w
|
||||
h_lbl = h / 9 - self.space
|
||||
|
||||
for label in self.labels:
|
||||
label.rescale(w_lbl, h_lbl)
|
||||
@@ -14,11 +14,12 @@ class ThreadStatus(Enum):
|
||||
NO_CONNECTION_ERR = auto()
|
||||
UNKNOWN_ERR = auto()
|
||||
BAD_DOWNLOAD_ERR = auto()
|
||||
UNDEFINED = auto()
|
||||
|
||||
class DownloadThread(QThread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.__status = ThreadStatus.OK
|
||||
self.__status = ThreadStatus.UNDEFINED
|
||||
self.reason = 0
|
||||
|
||||
@property
|
||||
@@ -55,12 +56,14 @@ class DownloadThread(QThread):
|
||||
zipped.extractall()
|
||||
except:
|
||||
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||
else:
|
||||
self.__status = ThreadStatus.OK
|
||||
|
||||
|
||||
class UpadteSpaceWeatherThread(QThread):
|
||||
def __init__(self, space_weather_data):
|
||||
super().__init__()
|
||||
self.__status = ThreadStatus.OK
|
||||
self.__status = ThreadStatus.UNDEFINED
|
||||
self.__space_weather_data = space_weather_data
|
||||
|
||||
@property
|
||||
@@ -89,3 +92,5 @@ class UpadteSpaceWeatherThread(QThread):
|
||||
self.__space_weather_data.images[8].loadFromData(urllib3.PoolManager().request('GET', Constants.FORECAST_IMG_8).data)
|
||||
except:
|
||||
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||
else:
|
||||
self.__status = ThreadStatus.OK
|
||||
|
||||
Reference in New Issue
Block a user