From 303ec2920723484a59dd5c86aa19b9e36495c7de Mon Sep 17 00:00:00 2001 From: Martin Fitzpatrick Date: Wed, 14 Feb 2018 01:11:47 +0100 Subject: [PATCH] weather: Add weather app using openweathermap.org API. --- README.md | 9 +- translate/mainwindow.ui | 41 +-- weather/MainWindow.py | 283 +++++++++++++++ weather/images/01d.png | Bin 0 -> 570 bytes weather/images/01n.png | Bin 0 -> 611 bytes weather/images/02d.png | Bin 0 -> 723 bytes weather/images/02n.png | Bin 0 -> 749 bytes weather/images/03d.png | Bin 0 -> 505 bytes weather/images/03n.png | Bin 0 -> 505 bytes weather/images/04d.png | Bin 0 -> 737 bytes weather/images/04n.png | Bin 0 -> 737 bytes weather/images/09d.png | Bin 0 -> 671 bytes weather/images/09n.png | Bin 0 -> 671 bytes weather/images/10d.png | Bin 0 -> 647 bytes weather/images/10n.png | Bin 0 -> 647 bytes weather/images/11d.png | Bin 0 -> 781 bytes weather/images/11n.png | Bin 0 -> 781 bytes weather/images/13d.png | Bin 0 -> 778 bytes weather/images/13n.png | Bin 0 -> 778 bytes weather/images/50d.png | Bin 0 -> 600 bytes weather/images/50n.png | Bin 0 -> 624 bytes weather/images/arrow-circle-225.png | Bin 0 -> 829 bytes weather/mainwindow.ui | 540 ++++++++++++++++++++++++++++ weather/weather.py | 94 +++++ 24 files changed, 930 insertions(+), 37 deletions(-) create mode 100644 weather/MainWindow.py create mode 100755 weather/images/01d.png create mode 100755 weather/images/01n.png create mode 100755 weather/images/02d.png create mode 100755 weather/images/02n.png create mode 100755 weather/images/03d.png create mode 100755 weather/images/03n.png create mode 100755 weather/images/04d.png create mode 100755 weather/images/04n.png create mode 100755 weather/images/09d.png create mode 100755 weather/images/09n.png create mode 100755 weather/images/10d.png create mode 100755 weather/images/10n.png create mode 100755 weather/images/11d.png create mode 100755 weather/images/11n.png create mode 100755 weather/images/13d.png create mode 100755 weather/images/13n.png create mode 100755 weather/images/50d.png create mode 100755 weather/images/50n.png create mode 100755 weather/images/arrow-circle-225.png create mode 100644 weather/mainwindow.ui create mode 100644 weather/weather.py diff --git a/README.md b/README.md index da8b434..f945cc7 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ found [on my site](http://martinfitzpatrick.name/tag/pyqt). All code is **licensed under an MIT license**. This allows you to re-use the code freely, -remixed in both commercial and non-commercial projects. The only requirement is that you must -include the MIT license file when distributing. +remixed in both commercial and non-commercial projects. The only requirement is to +include the same license when distributing. ## Completed @@ -29,13 +29,13 @@ include the MIT license file when distributing. 1. Media Player - "Failamp" 1. Post-it Notes - "Brown Note" (QtDesigner) 1. Paint - "Piecasso" (QtDesigner) -1. Translator - "Babelvis" (QtDesigner) 1. Unzip - "7Pez" (QtDesigner) +1. Translator - "Translataar" (QtDesigner) +1. Weather - "Raindar" (QtDesigner) ## In progress 1. Currency converter (QtDesigner, PyQtGraph) -1. RSS Reader (QtDesigner) ## Up next @@ -52,7 +52,6 @@ include the MIT license file when distributing. 1. (Audio) Spectrum Analyzer 1. IM (Jabber) 1. FTP -1. Weather 1. Finance/Stocks 1. Process Explorer 1. Internet Radio diff --git a/translate/mainwindow.ui b/translate/mainwindow.ui index 9b45680..ad04383 100644 --- a/translate/mainwindow.ui +++ b/translate/mainwindow.ui @@ -11,7 +11,7 @@ - Babelvis + Translataaaar @@ -31,14 +31,14 @@ - 50 - 75 + 75 + 50 - 50 - 75 + 75 + 50 @@ -49,43 +49,20 @@ - images/locale.pngimages/locale.png + images/flag.pngimages/flag.png - - - - - + - 50 - 75 + 75 + 50 - - - 50 - 75 - - - - Reverse translate - - - - - - - images/arrow-return-180.pngimages/arrow-return-180.png - - - - diff --git a/weather/MainWindow.py b/weather/MainWindow.py new file mode 100644 index 0000000..d9ac50a --- /dev/null +++ b/weather/MainWindow.py @@ -0,0 +1,283 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'mainwindow.ui' +# +# Created by: PyQt5 UI code generator 5.10 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(330, 417) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.horizontalLayout = QtWidgets.QHBoxLayout(self.centralwidget) + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout = QtWidgets.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) + self.lineEdit.setObjectName("lineEdit") + self.horizontalLayout_3.addWidget(self.lineEdit) + self.pushButton = QtWidgets.QPushButton(self.centralwidget) + self.pushButton.setText("") + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("images/arrow-circle-225.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.pushButton.setIcon(icon) + self.pushButton.setObjectName("pushButton") + self.horizontalLayout_3.addWidget(self.pushButton) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.horizontalLayout_4 = QtWidgets.QHBoxLayout() + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.weatherIcon = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.weatherIcon.sizePolicy().hasHeightForWidth()) + self.weatherIcon.setSizePolicy(sizePolicy) + self.weatherIcon.setMinimumSize(QtCore.QSize(16, 16)) + self.weatherIcon.setMaximumSize(QtCore.QSize(16, 16)) + self.weatherIcon.setText("") + self.weatherIcon.setObjectName("weatherIcon") + self.horizontalLayout_4.addWidget(self.weatherIcon) + self.weatherLabel = QtWidgets.QLabel(self.centralwidget) + self.weatherLabel.setText("") + self.weatherLabel.setObjectName("weatherLabel") + self.horizontalLayout_4.addWidget(self.weatherLabel) + self.verticalLayout.addLayout(self.horizontalLayout_4) + self.gridLayout_2 = QtWidgets.QGridLayout() + self.gridLayout_2.setObjectName("gridLayout_2") + self.forecastIcon4 = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.forecastIcon4.sizePolicy().hasHeightForWidth()) + self.forecastIcon4.setSizePolicy(sizePolicy) + self.forecastIcon4.setMinimumSize(QtCore.QSize(16, 16)) + self.forecastIcon4.setMaximumSize(QtCore.QSize(200, 16)) + self.forecastIcon4.setBaseSize(QtCore.QSize(0, 0)) + self.forecastIcon4.setText("") + self.forecastIcon4.setAlignment(QtCore.Qt.AlignCenter) + self.forecastIcon4.setObjectName("forecastIcon4") + self.gridLayout_2.addWidget(self.forecastIcon4, 1, 3, 1, 1) + self.forecastTemp2 = QtWidgets.QLabel(self.centralwidget) + self.forecastTemp2.setText("") + self.forecastTemp2.setObjectName("forecastTemp2") + self.gridLayout_2.addWidget(self.forecastTemp2, 2, 1, 1, 1) + self.forecastTemp5 = QtWidgets.QLabel(self.centralwidget) + self.forecastTemp5.setText("") + self.forecastTemp5.setObjectName("forecastTemp5") + self.gridLayout_2.addWidget(self.forecastTemp5, 2, 4, 1, 1) + self.forecastTemp4 = QtWidgets.QLabel(self.centralwidget) + self.forecastTemp4.setText("") + self.forecastTemp4.setObjectName("forecastTemp4") + self.gridLayout_2.addWidget(self.forecastTemp4, 2, 3, 1, 1) + self.forecastIcon2 = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.forecastIcon2.sizePolicy().hasHeightForWidth()) + self.forecastIcon2.setSizePolicy(sizePolicy) + self.forecastIcon2.setMinimumSize(QtCore.QSize(16, 16)) + self.forecastIcon2.setMaximumSize(QtCore.QSize(200, 16)) + self.forecastIcon2.setBaseSize(QtCore.QSize(0, 0)) + self.forecastIcon2.setText("") + self.forecastIcon2.setAlignment(QtCore.Qt.AlignCenter) + self.forecastIcon2.setObjectName("forecastIcon2") + self.gridLayout_2.addWidget(self.forecastIcon2, 1, 1, 1, 1) + self.forecastIcon5 = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.forecastIcon5.sizePolicy().hasHeightForWidth()) + self.forecastIcon5.setSizePolicy(sizePolicy) + self.forecastIcon5.setMinimumSize(QtCore.QSize(16, 16)) + self.forecastIcon5.setMaximumSize(QtCore.QSize(200, 16)) + self.forecastIcon5.setBaseSize(QtCore.QSize(0, 0)) + self.forecastIcon5.setText("") + self.forecastIcon5.setAlignment(QtCore.Qt.AlignCenter) + self.forecastIcon5.setObjectName("forecastIcon5") + self.gridLayout_2.addWidget(self.forecastIcon5, 1, 4, 1, 1) + self.forecastIcon1 = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.forecastIcon1.sizePolicy().hasHeightForWidth()) + self.forecastIcon1.setSizePolicy(sizePolicy) + self.forecastIcon1.setMinimumSize(QtCore.QSize(16, 16)) + self.forecastIcon1.setMaximumSize(QtCore.QSize(200, 16)) + self.forecastIcon1.setBaseSize(QtCore.QSize(0, 0)) + self.forecastIcon1.setText("") + self.forecastIcon1.setAlignment(QtCore.Qt.AlignCenter) + self.forecastIcon1.setObjectName("forecastIcon1") + self.gridLayout_2.addWidget(self.forecastIcon1, 1, 0, 1, 1) + self.forecastIcon3 = QtWidgets.QLabel(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.forecastIcon3.sizePolicy().hasHeightForWidth()) + self.forecastIcon3.setSizePolicy(sizePolicy) + self.forecastIcon3.setMinimumSize(QtCore.QSize(16, 16)) + self.forecastIcon3.setMaximumSize(QtCore.QSize(200, 16)) + self.forecastIcon3.setBaseSize(QtCore.QSize(0, 0)) + self.forecastIcon3.setText("") + self.forecastIcon3.setAlignment(QtCore.Qt.AlignCenter) + self.forecastIcon3.setObjectName("forecastIcon3") + self.gridLayout_2.addWidget(self.forecastIcon3, 1, 2, 1, 1) + self.forecastTemp3 = QtWidgets.QLabel(self.centralwidget) + self.forecastTemp3.setText("") + self.forecastTemp3.setObjectName("forecastTemp3") + self.gridLayout_2.addWidget(self.forecastTemp3, 2, 2, 1, 1) + self.forecastTemp1 = QtWidgets.QLabel(self.centralwidget) + self.forecastTemp1.setText("") + self.forecastTemp1.setObjectName("forecastTemp1") + self.gridLayout_2.addWidget(self.forecastTemp1, 2, 0, 1, 1) + self.forecastTime1 = QtWidgets.QLabel(self.centralwidget) + self.forecastTime1.setAlignment(QtCore.Qt.AlignCenter) + self.forecastTime1.setObjectName("forecastTime1") + self.gridLayout_2.addWidget(self.forecastTime1, 0, 0, 1, 1) + self.forecastTime2 = QtWidgets.QLabel(self.centralwidget) + self.forecastTime2.setAlignment(QtCore.Qt.AlignCenter) + self.forecastTime2.setObjectName("forecastTime2") + self.gridLayout_2.addWidget(self.forecastTime2, 0, 1, 1, 1) + self.forecastTime3 = QtWidgets.QLabel(self.centralwidget) + self.forecastTime3.setAlignment(QtCore.Qt.AlignCenter) + self.forecastTime3.setObjectName("forecastTime3") + self.gridLayout_2.addWidget(self.forecastTime3, 0, 2, 1, 1) + self.forecastTime4 = QtWidgets.QLabel(self.centralwidget) + self.forecastTime4.setAlignment(QtCore.Qt.AlignCenter) + self.forecastTime4.setObjectName("forecastTime4") + self.gridLayout_2.addWidget(self.forecastTime4, 0, 3, 1, 1) + self.forecastTime5 = QtWidgets.QLabel(self.centralwidget) + self.forecastTime5.setAlignment(QtCore.Qt.AlignCenter) + self.forecastTime5.setObjectName("forecastTime5") + self.gridLayout_2.addWidget(self.forecastTime5, 0, 4, 1, 1) + self.verticalLayout.addLayout(self.gridLayout_2) + self.gridLayout = QtWidgets.QGridLayout() + self.gridLayout.setObjectName("gridLayout") + self.formLayout = QtWidgets.QFormLayout() + self.formLayout.setObjectName("formLayout") + self.label_5 = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label_5.setFont(font) + self.label_5.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_5.setObjectName("label_5") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_5) + self.label_6 = QtWidgets.QLabel(self.centralwidget) + self.label_6.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_6.setObjectName("label_6") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_6) + self.temperatureLabel = QtWidgets.QLabel(self.centralwidget) + self.temperatureLabel.setText("") + self.temperatureLabel.setObjectName("temperatureLabel") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.temperatureLabel) + self.label_7 = QtWidgets.QLabel(self.centralwidget) + self.label_7.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_7.setObjectName("label_7") + self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_7) + self.humidityLabel = QtWidgets.QLabel(self.centralwidget) + self.humidityLabel.setText("") + self.humidityLabel.setObjectName("humidityLabel") + self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.humidityLabel) + self.label_8 = QtWidgets.QLabel(self.centralwidget) + self.label_8.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_8.setObjectName("label_8") + self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_8) + self.pressureLabel = QtWidgets.QLabel(self.centralwidget) + self.pressureLabel.setText("") + self.pressureLabel.setObjectName("pressureLabel") + self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.pressureLabel) + self.label = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label.setFont(font) + self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label.setObjectName("label") + self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.label) + self.label_2 = QtWidgets.QLabel(self.centralwidget) + self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_2.setObjectName("label_2") + self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.label_2) + self.longitudeLabel = QtWidgets.QLabel(self.centralwidget) + self.longitudeLabel.setText("") + self.longitudeLabel.setObjectName("longitudeLabel") + self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.longitudeLabel) + self.label_3 = QtWidgets.QLabel(self.centralwidget) + self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_3.setObjectName("label_3") + self.formLayout.setWidget(8, QtWidgets.QFormLayout.LabelRole, self.label_3) + self.latitudeLabel = QtWidgets.QLabel(self.centralwidget) + self.latitudeLabel.setText("") + self.latitudeLabel.setObjectName("latitudeLabel") + self.formLayout.setWidget(8, QtWidgets.QFormLayout.FieldRole, self.latitudeLabel) + self.label_4 = QtWidgets.QLabel(self.centralwidget) + self.label_4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_4.setObjectName("label_4") + self.formLayout.setWidget(9, QtWidgets.QFormLayout.LabelRole, self.label_4) + self.sunriseLabel = QtWidgets.QLabel(self.centralwidget) + self.sunriseLabel.setText("") + self.sunriseLabel.setObjectName("sunriseLabel") + self.formLayout.setWidget(9, QtWidgets.QFormLayout.FieldRole, self.sunriseLabel) + self.label_9 = QtWidgets.QLabel(self.centralwidget) + self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_9.setObjectName("label_9") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_9) + self.label_10 = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.label_10.setFont(font) + self.label_10.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label_10.setObjectName("label_10") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_10) + self.windLabel = QtWidgets.QLabel(self.centralwidget) + self.windLabel.setText("") + self.windLabel.setObjectName("windLabel") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.windLabel) + self.label_11 = QtWidgets.QLabel(self.centralwidget) + self.label_11.setText("") + self.label_11.setObjectName("label_11") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.label_11) + self.label_13 = QtWidgets.QLabel(self.centralwidget) + self.label_13.setText("") + self.label_13.setObjectName("label_13") + self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.label_13) + self.label_12 = QtWidgets.QLabel(self.centralwidget) + self.label_12.setText("") + self.label_12.setObjectName("label_12") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.label_12) + self.gridLayout.addLayout(self.formLayout, 1, 0, 1, 1) + self.verticalLayout.addLayout(self.gridLayout) + self.horizontalLayout.addLayout(self.verticalLayout) + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "Raindar")) + self.lineEdit.setText(_translate("MainWindow", "Utrecht,the Netherlands")) + self.forecastTime1.setText(_translate("MainWindow", "+3h")) + self.forecastTime2.setText(_translate("MainWindow", "+6h")) + self.forecastTime3.setText(_translate("MainWindow", "+9h")) + self.forecastTime4.setText(_translate("MainWindow", "+12h")) + self.forecastTime5.setText(_translate("MainWindow", "+15h")) + self.label_5.setText(_translate("MainWindow", "Barometer")) + self.label_6.setText(_translate("MainWindow", "Temperature")) + self.label_7.setText(_translate("MainWindow", "Humidity")) + self.label_8.setText(_translate("MainWindow", "Pressure")) + self.label.setText(_translate("MainWindow", "Location")) + self.label_2.setText(_translate("MainWindow", "Longitude")) + self.label_3.setText(_translate("MainWindow", "Latitude")) + self.label_4.setText(_translate("MainWindow", "Sunrise")) + self.label_9.setText(_translate("MainWindow", "Speed")) + self.label_10.setText(_translate("MainWindow", "Wind")) + diff --git a/weather/images/01d.png b/weather/images/01d.png new file mode 100755 index 0000000000000000000000000000000000000000..ff082c8a98501ce1789ee5bb52c0f04b606fcf73 GIT binary patch literal 570 zcmV-A0>%A_P)Vr@FRNj5u^nZzd{6_?#x z55Dl@P2PFt$$Y$FMN!a2g3|@VK7aW5h7*S!aPWEy+yKpbcnA(bkmsZTZ9dB<4eDrM zM~{%ZpaWWUU4T9C4SWE})Cv$zIT<`@wC+A!UVFaYm|wg~IHDvz{{3U;_4h>d7i#T0 zpe79Rf^I{+G2iNJb{@QZ%(G)RPee6#+2Tv98!y_sUtY0z5QHclfSm~gW9TN*+V$0^ zT{H4sU6{X1%Z#G2K5&~$_q&5I*hlH>ECUZ|!Exr=Dvhd|&NW3cB&j3fOp)VwZRpBv zcvEMfb#b zI2O=}`dTL&DK``tO?&?K`~EmPQ4UYZu~K{;a7oOJ)zSW0ztoi4SzGYYAUzR=*JN+R zm+yEhO^>%YGZYP_2>OYiMEVn?Jv5s?s}GdQiY+P0isE$e>t}keJk)yZ6l{afu1i~& zT&89jlo3lsZ_Cx7p;qvIrLLbbM!s#+E)3+q6WD+M8~+F}0D8;f_fJikr~m)}07*qo IM6N<$f)W!0&;S4c literal 0 HcmV?d00001 diff --git a/weather/images/01n.png b/weather/images/01n.png new file mode 100755 index 0000000000000000000000000000000000000000..545b6f9c26ae20a50781e3de8d476e3bcb780e5e GIT binary patch literal 611 zcmV-p0-XJcP)t`=key(TJQX{pUb*yt1?q1TU3g|KiQ!p!a_-^0D2<*2>`YS|&7Zq(zG`0w*lkhW1wjURI7(< z;rGO)Ui;S8vJK@^rqJWSKZRyaz| zUr)&L{FO{*@@}u!Pwem4w;4gY!-V1+Pvw;|01XijIkF2n2X= z7grR6j3^Fe3x(1it6A4p7v;5;NF+uZh5@>+L!)6rC?o;HFy2{JbvRjh2U`+Q*GC)8 zNmAejD~iH$x7+1PrRuY0Ggr8~*pe80JYJBp+_!szZ=&K?A13dX)LVO|dMPGyjmuMIa91JA< z=-RbwZ(GkDBWmEq(Dak$ocrzfYy3&3*#`0^Obh{W>sb&8mXfn{9x zgjz>J0SO~1qzj4E^Sj75WEt5*oRbWA+(j78v#GAk$nD23#*}zRJ1e$dS}(kR_j)d$ z`}z^XPjy50Zv&w(&IM7NPG0W4H~IY4GlTcVP3nl7+rLC5o@h$<4PIIQv83_rMTv@3jk5q zG%kRZRowv9jlzww35dm-K-Vo;Tify#i$?8jUc*LX1$l5Ub<&_7tIRK%5)wSPKHRn=o{i@MsEnU%}s zYN7CRfy~Z+c%!NZ%Kr?I=egC5jh*?`)y)~Mc3SM10sM8udhXbNtbY)T4HzLUc5`!= f$DMYZe+w`GxEc*C;iDKe00000NkvXXu0mjf(G6KW literal 0 HcmV?d00001 diff --git a/weather/images/03d.png b/weather/images/03d.png new file mode 100755 index 0000000000000000000000000000000000000000..49afdad8a6081e9b74a6de03597ebbbda9b0e027 GIT binary patch literal 505 zcmV#9il8n@g_nYw_AT8=$CZq-an8|L8n0RSP&h&l^=akDYU!o>V7!QY*vb=@DL3= z%)al;Jnu8_Gs_V|V4C5BDaYRvph96EFvfrofD>mYD1J_b6^dZ0ifRwYwlG~mo00000NkvXXu0mjf_N(b* literal 0 HcmV?d00001 diff --git a/weather/images/03n.png b/weather/images/03n.png new file mode 100755 index 0000000000000000000000000000000000000000..49afdad8a6081e9b74a6de03597ebbbda9b0e027 GIT binary patch literal 505 zcmV#9il8n@g_nYw_AT8=$CZq-an8|L8n0RSP&h&l^=akDYU!o>V7!QY*vb=@DL3= z%)al;Jnu8_Gs_V|V4C5BDaYRvph96EFvfrofD>mYD1J_b6^dZ0ifRwYwlG~mo00000NkvXXu0mjf_N(b* literal 0 HcmV?d00001 diff --git a/weather/images/04d.png b/weather/images/04d.png new file mode 100755 index 0000000000000000000000000000000000000000..732c635f08874032f8088f4a3cd2d90cdda31cd8 GIT binary patch literal 737 zcmV<70v`Q|P)OoV%w%9_&iVH=G71WDZ>Ot@i_!IgIdg-l)dJw$np&-&j1+j=N6-q^Ws;1VD zMs4;Z$!5PhyY&O{R2&#)_MLs7dEV!JCggb@++>8|h64=@Oha8=9Uz2&qNoVRu~KVm zdelEG6n@VuO8EoXn&%0&ZG+=DmjLG**L8vCdB;A}ph6RK4UwzhUg*Vi}K{Bz5) z4}HMXQ{@Vv4-kpRqmn3QMq66y@3pmM1;PYku`pz_Ekb8!+cSotKvnesaAxM+i&9Bj zx&Vm97-?eS>8vPb1*;Ff5Q|EhsBcIvj>X;uc^`5e>{HS(XFcXqpDJu<-tkEdOabN2FFw=) zAW7ZvOh$l8#Ux@DVPj)cU0wbBX>IM>OHmXd8jS{mQVf$ls8p=E<70KMSXAc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)ba0dsAP;PE+ z)}KFrf;EE_^7He9ZT|lKI|C>jV1Wnn5=aclXB80Owq@bx=XUt~`4j86Z(mWO2jmiT z05TjF*g!*mKYjZA8q22z>f0Ae;E<^^IAAO;yG z1;PperBX09R2(GF2U5?%BErbUr43F8AkY1R;?KM)<_yx_g$yD(c80*{jpI|ZEWFee zgwr)B2}w0)DFcs+87N%@v9tUQmlS2=`u5F$K|OC7!_7%iSPfu;F=SKbFfdE&00ZY6 z!`H800>j*7ly5(H{q4(_&kT%`+F*HXfEh&a+ov#a=y(9*`VScY`t_Uf;OWOAU%via z^XJc>>mV^kUNLZJ{d{;1VlxvLFq(N77%9$;lo|jKU;sB{;ZM4B(^UWf002ovPDHLk FV1izxED`_! literal 0 HcmV?d00001 diff --git a/weather/images/09n.png b/weather/images/09n.png new file mode 100755 index 0000000000000000000000000000000000000000..e3dea9bf68ac3ead1c5f43912009135b872b994a GIT binary patch literal 671 zcmV;Q0$}}#P)=0GaP#7XJJ9kKzCSe+(?hrhz0G85xDV zylndY{aqu4g@swaeEGug;>C-og9lIBZ{L2j5M&6l9%ey7RiN!mK#fcwBN%`-MFFE8tlA3qSbfDPhcjfn~Jfq3av)Yh&0?04=wTEGJIhp>x_)g&Ju=TIIV9@bBv zJ~4dz_Kks+6&@Z8pFe+Q`2G7g!>?bzKwe}J6ck{!u`vq2e*Nwd7Fk)ba0dsAP;PE+ z)}KFrf;EE_^7He9ZT|lKI|C>jV1Wnn5=aclXB80Owq@bx=XUt~`4j86Z(mWO2jmiT z05TjF*g!*mKYjZA8q22z>f0Ae;E<^^IAAO;yG z1;PperBX09R2(GF2U5?%BErbUr43F8AkY1R;?KM)<_yx_g$yD(c80*{jpI|ZEWFee zgwr)B2}w0)DFcs+87N%@v9tUQmlS2=`u5F$K|OC7!_7%iSPfu;F=SKbFfdE&00ZY6 z!`H800>j*7ly5(H{q4(_&kT%`+F*HXfEh&a+ov#a=y(9*`VScY`t_Uf;OWOAU%via z^XJc>>mV^kUNLZJ{d{;1VlxvLFq(N77%9$;lo|jKU;sB{;ZM4B(^UWf002ovPDHLk FV1izxED`_! literal 0 HcmV?d00001 diff --git a/weather/images/10d.png b/weather/images/10d.png new file mode 100755 index 0000000000000000000000000000000000000000..5c91a388a8d30bd4ea6f4dfbc7a486982e2365bc GIT binary patch literal 647 zcmV;20(kw2P)^@RCwBA{Qv(y10{e(S=oz$nVFe^ ziHVtkg@qL+E~KI&8z3$&YzN}JeEIg!ojZ>=0GaP#7XJJ9kKzCSe+(?hrhz0G85xDV zylndY{aqu4g@swaeEGug;>C-og9lIBZ{L2j5M&6l9%ey7RiN!mK#fcwBN%`-MFFE8tlA3qSbfDPhcjfn~Jfq3av)Yh&0?04=wTEGJIhp>x_)g&Ju=TIIV9@bBv zJ~4dz_Kks+6&@Z8pFe+Q`2G7g!>?bzKwe}J6ck{!u`vq2e*Nwd7Fk)ba0dsAP;PE+ z)}KFrf;EE_^7He9ZT|lKI|C>jV1Wnn5=aclXB80Owq@bx=XUt~`4j86Z(mWO2jmiT z05TjF*g!*mKYjZA8q22wgE5s2A^@RCwBA{Qv(y10{e(S=oz$nVFe^ ziHVtkg@qL+E~KI&8z3$&YzN}JeEIg!ojZ>=0GaP#7XJJ9kKzCSe+(?hrhz0G85xDV zylndY{aqu4g@swaeEGug;>C-og9lIBZ{L2j5M&6l9%ey7RiN!mK#fcwBN%`-MFFE8tlA3qSbfDPhcjfn~Jfq3av)Yh&0?04=wTEGJIhp>x_)g&Ju=TIIV9@bBv zJ~4dz_Kks+6&@Z8pFe+Q`2G7g!>?bzKwe}J6ck{!u`vq2e*Nwd7Fk)ba0dsAP;PE+ z)}KFrf;EE_^7He9ZT|lKI|C>jV1Wnn5=aclXB80Owq@bx=XUt~`4j86Z(mWO2jmiT z05TjF*g!*mKYjZA8q22wgE5s2AWdP)b*|c$0z@=5S_n z1y*MN1IES^l`NEUd)=OOmgMq~3 zaS%lj2>G)QNF)-F&1ON8BswCP&Bes$tLt7`S_$xOx1+nMslH3E*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@hlg-fwVI? zCS?acm@DITivg2l6%wasN&{`RF+*`)(E%Cn<6piP~s&=wZqmXoPT29r&UwrHd9s zPTYgWuI|6CVR0#C&pm!{n7~c`d2}zC;6H9LnX*ab`z^o#mJz0K(>U?q00000NkvXX Hu0mjf{2PC* literal 0 HcmV?d00001 diff --git a/weather/mainwindow.ui b/weather/mainwindow.ui new file mode 100644 index 0000000..32778fa --- /dev/null +++ b/weather/mainwindow.ui @@ -0,0 +1,540 @@ + + + MainWindow + + + + 0 + 0 + 330 + 417 + + + + Raindar + + + + + + + + + + + Utrecht,the Netherlands + + + + + + + + + + + images/arrow-circle-225.pngimages/arrow-circle-225.png + + + + + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 200 + 16 + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 200 + 16 + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 200 + 16 + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 200 + 16 + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16 + 16 + + + + + 200 + 16 + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + + + + + + + + + + + + + + +3h + + + Qt::AlignCenter + + + + + + + +6h + + + Qt::AlignCenter + + + + + + + +9h + + + Qt::AlignCenter + + + + + + + +12h + + + Qt::AlignCenter + + + + + + + +15h + + + Qt::AlignCenter + + + + + + + + + + + + + + 75 + true + + + + Barometer + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Temperature + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Humidity + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Pressure + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + 75 + true + + + + Location + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Longitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Latitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Sunrise + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + Speed + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + Wind + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weather/weather.py b/weather/weather.py new file mode 100644 index 0000000..dbf53bf --- /dev/null +++ b/weather/weather.py @@ -0,0 +1,94 @@ +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from PyQt5.QtCore import * + +from MainWindow import Ui_MainWindow + +from datetime import datetime +import json +import os +import sys +import requests +from urllib.parse import urlencode + +OPENWEATHERMAP_API_KEY = os.environ.get('OPENWEATHERMAP_API_KEY') + +""" +Get an API key from https://openweathermap.org/ to use with this +application. + +""" + +class MainWindow(QMainWindow, Ui_MainWindow): + + def __init__(self, *args, **kwargs): + super(MainWindow, self).__init__(*args, **kwargs) + self.setupUi(self) + + self.pushButton.pressed.connect(self.update_weather) + self.pushButton.pressed.connect(self.update_forecast) + + self.show() + + def from_ts_to_time_of_day(self, ts): + dt = datetime.fromtimestamp(ts) + return dt.strftime("%I%p").lstrip("0") + + def update_weather(self): + params = dict( + q=self.lineEdit.text(), + appid=OPENWEATHERMAP_API_KEY + ) + + url = 'http://api.openweathermap.org/data/2.5/weather?%s&units=metric' % urlencode(params) + r = requests.get(url) + data = json.loads(r.text) + + self.latitudeLabel.setText("%.2f °" % data['coord']['lat']) + self.longitudeLabel.setText("%.2f °" % data['coord']['lon']) + + self.windLabel.setText("%.2f m/s" % data['wind']['speed']) + + self.temperatureLabel.setText("%.1f °C" % data['main']['temp']) + self.pressureLabel.setText("%d" % data['main']['pressure']) + self.humidityLabel.setText("%d" % data['main']['humidity']) + + self.sunriseLabel.setText(self.from_ts_to_time_of_day(data['sys']['sunrise'])) + + self.weatherLabel.setText("%s (%s)" % ( + data['weather'][0]['main'], + data['weather'][0]['description'] + ) + ) + + self.set_weather_icon(self.weatherIcon, data['weather']) + + def set_weather_icon(self, label, weather): + label.setPixmap( + QPixmap(os.path.join('images', "%s.png" % + weather[0]['icon'] + ) + ) + + ) + + def update_forecast(self): + params = dict( + q=self.lineEdit.text(), + appid=OPENWEATHERMAP_API_KEY + ) + + url = 'http://api.openweathermap.org/data/2.5/forecast?%s&units=metric' % urlencode(params) + r = requests.get(url) + data = json.loads(r.text) + + for n, forecast in enumerate(data['list'][:5], 1): + getattr(self, 'forecastTime%d' % n).setText(self.from_ts_to_time_of_day(forecast['dt'])) + self.set_weather_icon(getattr(self, 'forecastIcon%d' % n), forecast['weather']) + getattr(self, 'forecastTemp%d' % n).setText("%.1f °C" % forecast['main']['temp']) + +if __name__ == '__main__': + + app = QApplication([]) + window = MainWindow() + app.exec_() \ No newline at end of file