def __init__(self): QMainWindow.__init__(self) Ui_mainWindow.__init__(self) self.setWindowTitle('derp') self.show() self.setupUi(self) self.selectedForecast = None self.fetcher = Fetcher() self.getCityByIp() self.btn_Search.clicked.connect(lambda: self.searchForecast(self.line_City.text()))
class MyApp(QMainWindow, Ui_mainWindow): def __init__(self): QMainWindow.__init__(self) Ui_mainWindow.__init__(self) self.setWindowTitle('derp') self.show() self.setupUi(self) self.selectedForecast = None self.fetcher = Fetcher() self.getCityByIp() self.btn_Search.clicked.connect(lambda: self.searchForecast(self.line_City.text())) def getCityByIp(self): if not self.fetcher.checkIpPrompt(): reply = QtGui.QMessageBox.question(self, 'Message', "Weather Seeker is trying to fetch your IP to get your location for easy weather show. This prompt will not show again, unless changed from settings, do you want to give permission for this?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self.searchForecast(self.fetcher.readCityByIp()) self.fetcher.changeIpChecking(True) else: self.fetcher.changeIpChecking(False) elif self.fetcher.checkIpChecking(): self.searchForecast(self.fetcher.readCityByIp()) def searchForecast(self, cityname): forecast = self.fetcher.readOpenWeatherMapJson(cityname) if forecast: self.selectedForecast = forecast ##TODAY self.lbl_Temperature.setText(str(self.selectedForecast.today.getTemp())) self.lbl_Weather.setText(str(self.selectedForecast.today.getWeather())) self.lbl_WindSpeed.setText(str(self.selectedForecast.today.getWindSpeed())) ##DAY1 self.lbl_Temperature_day1.setText(str(self.selectedForecast.day1.getTemp())) self.lbl_Weather_day1.setText(str(self.selectedForecast.day1.getWeather())) self.lbl_date_day1.setText(str(self.selectedForecast.day1.getDate())) self.lbl_WindSpeed_day1.setText(str(self.selectedForecast.day1.getWindSpeed())) ##DAY2 self.lbl_Temperature_day2.setText(str(self.selectedForecast.day2.getTemp())) self.lbl_Weather_day2.setText(str(self.selectedForecast.day2.getWeather())) self.lbl_date_day2.setText(str(self.selectedForecast.day2.getDate())) self.lbl_WindSpeed_day2.setText(str(self.selectedForecast.day2.getWindSpeed())) ##DAY3 self.lbl_Temperature_day3.setText(str(self.selectedForecast.day3.getTemp())) self.lbl_Weather_day3.setText(str(self.selectedForecast.day3.getWeather())) self.lbl_date_day3.setText(str(self.selectedForecast.day3.getDate())) self.lbl_WindSpeed_day3.setText(str(self.selectedForecast.day3.getWindSpeed())) ##DAY4 self.lbl_Temperature_day4.setText(str(self.selectedForecast.day4.getTemp())) self.lbl_Weather_day4.setText(str(self.selectedForecast.day4.getWeather())) self.lbl_date_day4.setText(str(self.selectedForecast.day4.getDate())) self.lbl_WindSpeed_day4.setText(str(self.selectedForecast.day4.getWindSpeed())) ##DAY5 self.lbl_Temperature_day5.setText(str(self.selectedForecast.day5.getTemp())) self.lbl_Weather_day5.setText(str(self.selectedForecast.day5.getWeather())) self.lbl_date_day5.setText(str(self.selectedForecast.day5.getDate())) self.lbl_WindSpeed_day5.setText(str(self.selectedForecast.day5.getWindSpeed())) self.lbl_CityName.setText(str(self.selectedForecast.getCity()))