♻️ Refactored UserInterface.py
This commit is contained in:
parent
f1110d4f07
commit
75fae905bf
|
@ -353,7 +353,7 @@ class Analyser:
|
||||||
|
|
||||||
largestData.plot.bar(ax=ax, x="countriesAndTerritories", y="casesPerMillion")
|
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():
|
for ticks in ax.xaxis.get_major_ticks():
|
||||||
if ticks.label1.get_text() == country:
|
if ticks.label1.get_text() == country:
|
||||||
ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r')
|
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")
|
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():
|
for ticks in ax.xaxis.get_major_ticks():
|
||||||
if ticks.label1.get_text() == country:
|
if ticks.label1.get_text() == country:
|
||||||
ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r')
|
ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r')
|
||||||
|
|
|
@ -113,6 +113,7 @@ class UserInterface(QMainWindow):
|
||||||
self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||||
|
|
||||||
self.setCentralWidget(self.scrollArea)
|
self.setCentralWidget(self.scrollArea)
|
||||||
|
#self.setLayout(layout)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def btnstate(self):
|
def btnstate(self):
|
||||||
|
@ -134,36 +135,37 @@ class UserInterface(QMainWindow):
|
||||||
+ ', <font color="red">Total Deaths:</font> ' + str(self.analyser.getTotalDeaths(country, endDate))
|
+ ', <font color="red">Total Deaths:</font> ' + str(self.analyser.getTotalDeaths(country, endDate))
|
||||||
+ ', <font color="red">Death Rate:</font> ' + str(self.analyser.getDeathRate(country, endDate))[:4]
|
+ ', <font color="red">Death Rate:</font> ' + str(self.analyser.getDeathRate(country, endDate))[:4]
|
||||||
+ '%</h4>'))
|
+ '%</h4>'))
|
||||||
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.graphPlaceHolder = QLabel(self)
|
||||||
self.clearLayout(self.graphBox)
|
self.clearLayout(self.graphBox)
|
||||||
self.graphBox.addWidget(self.graphPlaceHolder)
|
self.graphBox.addWidget(self.graphPlaceHolder)
|
||||||
|
|
||||||
if self.graphTypePicker.currentText() == 'Total Cases':
|
if self.graphTypePicker.currentText() == 'Total Cases':
|
||||||
|
casesGraphPath = self.analyser.getCasesGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(casesGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(casesGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Case Increase':
|
elif self.graphTypePicker.currentText() == 'Case Increase':
|
||||||
|
caseIncreaseGraphPath = self.analyser.getCaseIncreaseGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(caseIncreaseGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(caseIncreaseGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Increase Percentage':
|
elif self.graphTypePicker.currentText() == 'Increase Percentage':
|
||||||
|
increasePercentageGraphPath = self.analyser.getIncreasePercentageGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(increasePercentageGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(increasePercentageGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Total Deaths':
|
elif self.graphTypePicker.currentText() == 'Total Deaths':
|
||||||
|
deathGraphPath = self.analyser.getDeathGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(deathGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(deathGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Death Increase':
|
elif self.graphTypePicker.currentText() == 'Death Increase':
|
||||||
|
deathIncreaseGraphPath = self.analyser.getDeathIncreaseGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(deathIncreaseGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(deathIncreaseGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Death Rate':
|
elif self.graphTypePicker.currentText() == 'Death Rate':
|
||||||
|
deathRateGraphPath = self.analyser.getDailyDeathRateGraph(country, startDate, endDate)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(deathRateGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(deathRateGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Is it going to end soon?':
|
elif self.graphTypePicker.currentText() == 'Is it going to end soon?':
|
||||||
|
isItOverGraphPath = self.analyser.getIsItOverGraph(country)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(isItOverGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(isItOverGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Cases per Million':
|
elif self.graphTypePicker.currentText() == 'Cases per Million':
|
||||||
|
casesPerMillionGraphPath = self.analyser.getCasesPerMillionGraph(country)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(casesPerMillionGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(casesPerMillionGraphPath))
|
||||||
elif self.graphTypePicker.currentText() == 'Deaths per Million':
|
elif self.graphTypePicker.currentText() == 'Deaths per Million':
|
||||||
|
deathsPerMillionGraphPath = self.analyser.getDeathsPerMillionGraph(country)
|
||||||
self.graphPlaceHolder.setPixmap(QPixmap(deathsPerMillionGraphPath))
|
self.graphPlaceHolder.setPixmap(QPixmap(deathsPerMillionGraphPath))
|
||||||
|
|
||||||
def clearLayout(self, layout):
|
def clearLayout(self, layout):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user