Fixed a problem with the window size

This commit is contained in:
Patrick Müller 2020-04-13 18:35:13 +02:00
parent 36539b64b2
commit 982e0ba1da
2 changed files with 241 additions and 36 deletions

View File

@ -12,7 +12,7 @@ from PyQt5.QtCore import *
import Analyser as ana
class UserInterface(QMainWindow):
class UserInterface(QWidget):
def __init__(self, app):
super().__init__()
# Get Analyser instance and required stuff from it
@ -24,8 +24,8 @@ class UserInterface(QMainWindow):
# PyQT Setup
self.setWindowTitle('COVID-19 Analytics')
screen_width, screen_height = app.desktop().screenGeometry().width(), app.desktop().screenGeometry().height()
self.setGeometry(((screen_width / 2) - 750), ((screen_height / 2) - 375), 1500, 750)
self.setMinimumWidth(1500)
self.setGeometry(((screen_width / 2) - 500), ((screen_height / 2) - 250), 1000, 500)
self.setMinimumWidth(1000)
self.setMinimumHeight(500)
# Plot DPI Settings
@ -33,11 +33,11 @@ class UserInterface(QMainWindow):
# Layout boxes
self.header_box = QHBoxLayout()
h2box1 = QHBoxLayout()
labelBox = QHBoxLayout()
picklistBox = QHBoxLayout()
buttonBox = QHBoxLayout()
caseNumberBox = QHBoxLayout()
self.h2box1 = QHBoxLayout()
self.labelBox = QHBoxLayout()
self.picklistBox = QHBoxLayout()
self.buttonBox = QHBoxLayout()
self.caseNumberBox = QHBoxLayout()
self.graphBox = QHBoxLayout()
# Heading
@ -46,78 +46,78 @@ class UserInterface(QMainWindow):
# Sub-Header
subheader1 = QLabel('<h2>Statistics about one country</h2>')
h2box1.addWidget(subheader1)
self.h2box1.addWidget(subheader1)
# Country Picker
countryPickerLabel = QLabel('<h3>Pick a country:</h3>')
labelBox.addWidget(countryPickerLabel)
# self.countryPicker = QComboBox(parent=self)
self.labelBox.addWidget(countryPickerLabel)
# self.countryPicker = QComboBox()
# self.countryPicker.addItems(countries)
# self.countryPicker.setCurrentText('Germany')
# picklistBox.addWidget(self.countryPicker, 1)
self.countryPicker = QLineEdit()
self.countryPicker.setCompleter(QCompleter(countries))
self.countryPicker.setText('Germany')
picklistBox.addWidget(self.countryPicker, 1)
self.picklistBox.addWidget(self.countryPicker, 1)
# Start Date Picker
startDatePickerLabel = QLabel('<h3>Pick a start date:</h3>')
labelBox.addWidget(startDatePickerLabel)
self.startDatePicker = QComboBox(parent=self)
self.labelBox.addWidget(startDatePickerLabel)
self.startDatePicker = QComboBox()
self.startDatePicker.addItems(dates)
self.startDatePicker.setCurrentText('2019-12-31')
picklistBox.addWidget(self.startDatePicker, 1)
self.picklistBox.addWidget(self.startDatePicker, 1)
# End Date Picker
endDatePickerLabel = QLabel('<h3>Pick an end date:</h3>')
labelBox.addWidget(endDatePickerLabel)
self.endDatePicker = QComboBox(parent=self)
self.labelBox.addWidget(endDatePickerLabel)
self.endDatePicker = QComboBox()
self.endDatePicker.addItems(dates)
self.endDatePicker.setCurrentText(dates[len(dates) - 1])
picklistBox.addWidget(self.endDatePicker, 1)
self.picklistBox.addWidget(self.endDatePicker, 1)
# Graph Type Picker
graphTypePickerLabel = QLabel('<h3>Pick a graph type:</h3>')
labelBox.addWidget(graphTypePickerLabel)
self.graphTypePicker = QComboBox(parent=self)
self.labelBox.addWidget(graphTypePickerLabel)
self.graphTypePicker = QComboBox()
self.graphTypePicker.addItems(
['Total Cases', 'Case Increase', 'Increase Percentage', 'Cases per Million', 'Total Deaths',
'Death Increase', 'Death Rate', 'Deaths per Million', 'Is it going to end soon?',
'Double Rate Compare'])
picklistBox.addWidget(self.graphTypePicker, 1)
self.picklistBox.addWidget(self.graphTypePicker, 1)
# Calculate Button
self.calculateSingleCountryStats = QPushButton('Calculate')
buttonBox.addWidget(self.calculateSingleCountryStats)
self.buttonBox.addWidget(self.calculateSingleCountryStats)
self.calculateSingleCountryStats.setCheckable(True)
self.calculateSingleCountryStats.clicked.connect(self.btnstate)
# Total cases number
self.casesNumber = QLabel('<h4>Total Case Number: NaN</h4>')
caseNumberBox.addWidget(self.casesNumber)
self.casesNumber = QLabel('<h4>Daily Statistics appear here once you click "Calculate"</h4>')
self.caseNumberBox.addWidget(self.casesNumber)
# Generate Layout
layout = QVBoxLayout()
layout.addLayout(self.header_box)
layout.addSpacing(50)
layout.addLayout(h2box1)
layout.addLayout(self.h2box1)
layout.addSpacing(10)
layout.addLayout(labelBox)
layout.addLayout(picklistBox)
layout.addLayout(self.labelBox)
layout.addLayout(self.picklistBox)
layout.addSpacing(10)
layout.addLayout(buttonBox)
layout.addLayout(self.buttonBox)
layout.addSpacing(10)
layout.addLayout(caseNumberBox)
layout.addLayout(self.caseNumberBox)
layout.addSpacing(10)
layout.addLayout(self.graphBox)
layout.addStretch(1)
self.scrollArea = QScrollArea()
self.scrollArea.setLayout(layout)
self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.setCentralWidget(self.scrollArea)
# self.setLayout(layout)
# self.scrollArea = QScrollArea()
# self.scrollArea.setLayout(layout)
# self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
#
# self.setCentralWidget(self.scrollArea)
self.setLayout(layout)
self.show()
def btnstate(self):

File diff suppressed because it is too large Load Diff