From 75fae905bf96a6f73691b031d57440e25060e0d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Fri, 10 Apr 2020 22:41:17 +0200 Subject: [PATCH] :recycle: Refactored UserInterface.py --- Analyser.py | 4 ++-- UserInterface.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Analyser.py b/Analyser.py index c47ac72..1934621 100644 --- a/Analyser.py +++ b/Analyser.py @@ -353,7 +353,7 @@ class Analyser: largestData.plot.bar(ax=ax, x="countriesAndTerritories", y="casesPerMillion") - # Hightlight the selected country + # Highlight the selected country for ticks in ax.xaxis.get_major_ticks(): if ticks.label1.get_text() == country: ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r') @@ -385,7 +385,7 @@ class Analyser: largestData.plot.bar(ax=ax, x="countriesAndTerritories", y="deathsPerMillion") - # Hightlight the selected country + # Highlight the selected country for ticks in ax.xaxis.get_major_ticks(): if ticks.label1.get_text() == country: ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r') diff --git a/UserInterface.py b/UserInterface.py index 143892f..ecdd6c9 100644 --- a/UserInterface.py +++ b/UserInterface.py @@ -113,6 +113,7 @@ class UserInterface(QMainWindow): self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setCentralWidget(self.scrollArea) + #self.setLayout(layout) self.show() def btnstate(self): @@ -134,36 +135,37 @@ class UserInterface(QMainWindow): + ', Total Deaths: ' + str(self.analyser.getTotalDeaths(country, endDate)) + ', Death Rate: ' + str(self.analyser.getDeathRate(country, endDate))[:4] + '%')) - casesGraphPath = self.analyser.getCasesGraph(country, startDate, endDate) - caseIncreaseGraphPath = self.analyser.getCaseIncreaseGraph(country, startDate, endDate) - increasePercentageGraphPath = self.analyser.getIncreasePercentageGraph(country, startDate, endDate) - deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate) - deathIncreaseGraphPath = self.analyser.getDeathIncreaseGraph(country, startDate, endDate) - deathRateGraphPath = self.analyser.getDailyDeathRateGraph(country, startDate, endDate) - isItOverGraphPath = self.analyser.getIsItOverGraph(country) - casesPerMillionGraphPath = self.analyser.getCasesPerMillionGraph(country) - deathsPerMillionGraphPath = self.analyser.getDeathsPerMillionGraph(country) + self.graphPlaceHolder = QLabel(self) self.clearLayout(self.graphBox) self.graphBox.addWidget(self.graphPlaceHolder) if self.graphTypePicker.currentText() == 'Total Cases': + casesGraphPath = self.analyser.getCasesGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(casesGraphPath)) elif self.graphTypePicker.currentText() == 'Case Increase': + caseIncreaseGraphPath = self.analyser.getCaseIncreaseGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(caseIncreaseGraphPath)) elif self.graphTypePicker.currentText() == 'Increase Percentage': + increasePercentageGraphPath = self.analyser.getIncreasePercentageGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(increasePercentageGraphPath)) elif self.graphTypePicker.currentText() == 'Total Deaths': + deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(deathGraphPath)) elif self.graphTypePicker.currentText() == 'Death Increase': + deathIncreaseGraphPath = self.analyser.getDeathIncreaseGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(deathIncreaseGraphPath)) elif self.graphTypePicker.currentText() == 'Death Rate': + deathRateGraphPath = self.analyser.getDailyDeathRateGraph(country, startDate, endDate) self.graphPlaceHolder.setPixmap(QPixmap(deathRateGraphPath)) elif self.graphTypePicker.currentText() == 'Is it going to end soon?': + isItOverGraphPath = self.analyser.getIsItOverGraph(country) self.graphPlaceHolder.setPixmap(QPixmap(isItOverGraphPath)) elif self.graphTypePicker.currentText() == 'Cases per Million': + casesPerMillionGraphPath = self.analyser.getCasesPerMillionGraph(country) self.graphPlaceHolder.setPixmap(QPixmap(casesPerMillionGraphPath)) elif self.graphTypePicker.currentText() == 'Deaths per Million': + deathsPerMillionGraphPath = self.analyser.getDeathsPerMillionGraph(country) self.graphPlaceHolder.setPixmap(QPixmap(deathsPerMillionGraphPath)) def clearLayout(self, layout):