weather: Add weather app using openweathermap.org API.
@ -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,
|
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
|
remixed in both commercial and non-commercial projects. The only requirement is to
|
||||||
include the MIT license file when distributing.
|
include the same license when distributing.
|
||||||
|
|
||||||
## Completed
|
## Completed
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ include the MIT license file when distributing.
|
|||||||
1. Media Player - "Failamp"
|
1. Media Player - "Failamp"
|
||||||
1. Post-it Notes - "Brown Note" (QtDesigner)
|
1. Post-it Notes - "Brown Note" (QtDesigner)
|
||||||
1. Paint - "Piecasso" (QtDesigner)
|
1. Paint - "Piecasso" (QtDesigner)
|
||||||
1. Translator - "Babelvis" (QtDesigner)
|
|
||||||
1. Unzip - "7Pez" (QtDesigner)
|
1. Unzip - "7Pez" (QtDesigner)
|
||||||
|
1. Translator - "Translataar" (QtDesigner)
|
||||||
|
1. Weather - "Raindar" (QtDesigner)
|
||||||
|
|
||||||
## In progress
|
## In progress
|
||||||
|
|
||||||
1. Currency converter (QtDesigner, PyQtGraph)
|
1. Currency converter (QtDesigner, PyQtGraph)
|
||||||
1. RSS Reader (QtDesigner)
|
|
||||||
|
|
||||||
## Up next
|
## Up next
|
||||||
|
|
||||||
@ -52,7 +52,6 @@ include the MIT license file when distributing.
|
|||||||
1. (Audio) Spectrum Analyzer
|
1. (Audio) Spectrum Analyzer
|
||||||
1. IM (Jabber)
|
1. IM (Jabber)
|
||||||
1. FTP
|
1. FTP
|
||||||
1. Weather
|
|
||||||
1. Finance/Stocks
|
1. Finance/Stocks
|
||||||
1. Process Explorer
|
1. Process Explorer
|
||||||
1. Internet Radio
|
1. Internet Radio
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Babelvis</string>
|
<string>Translataaaar</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@ -31,14 +31,14 @@
|
|||||||
<widget class="QPushButton" name="translateButton">
|
<widget class="QPushButton" name="translateButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>75</width>
|
||||||
<height>75</height>
|
<height>50</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>75</width>
|
||||||
<height>75</height>
|
<height>50</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -49,43 +49,20 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset>
|
<iconset>
|
||||||
<normaloff>images/locale.png</normaloff>images/locale.png</iconset>
|
<normaloff>images/flag.png</normaloff>images/flag.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="iconSize">
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="reverseButton">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>75</width>
|
||||||
<height>75</height>
|
<height>50</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>50</width>
|
|
||||||
<height>75</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Reverse translate</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset>
|
|
||||||
<normaloff>images/arrow-return-180.png</normaloff>images/arrow-return-180.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="destLanguage"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="destTextEdit"/>
|
<widget class="QTextEdit" name="destTextEdit"/>
|
||||||
</item>
|
</item>
|
||||||
|
283
weather/MainWindow.py
Normal file
@ -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"))
|
||||||
|
|
BIN
weather/images/01d.png
Executable file
After Width: | Height: | Size: 570 B |
BIN
weather/images/01n.png
Executable file
After Width: | Height: | Size: 611 B |
BIN
weather/images/02d.png
Executable file
After Width: | Height: | Size: 723 B |
BIN
weather/images/02n.png
Executable file
After Width: | Height: | Size: 749 B |
BIN
weather/images/03d.png
Executable file
After Width: | Height: | Size: 505 B |
BIN
weather/images/03n.png
Executable file
After Width: | Height: | Size: 505 B |
BIN
weather/images/04d.png
Executable file
After Width: | Height: | Size: 737 B |
BIN
weather/images/04n.png
Executable file
After Width: | Height: | Size: 737 B |
BIN
weather/images/09d.png
Executable file
After Width: | Height: | Size: 671 B |
BIN
weather/images/09n.png
Executable file
After Width: | Height: | Size: 671 B |
BIN
weather/images/10d.png
Executable file
After Width: | Height: | Size: 647 B |
BIN
weather/images/10n.png
Executable file
After Width: | Height: | Size: 647 B |
BIN
weather/images/11d.png
Executable file
After Width: | Height: | Size: 781 B |
BIN
weather/images/11n.png
Executable file
After Width: | Height: | Size: 781 B |
BIN
weather/images/13d.png
Executable file
After Width: | Height: | Size: 778 B |
BIN
weather/images/13n.png
Executable file
After Width: | Height: | Size: 778 B |
BIN
weather/images/50d.png
Executable file
After Width: | Height: | Size: 600 B |
BIN
weather/images/50n.png
Executable file
After Width: | Height: | Size: 624 B |
BIN
weather/images/arrow-circle-225.png
Executable file
After Width: | Height: | Size: 829 B |
540
weather/mainwindow.ui
Normal file
@ -0,0 +1,540 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>330</width>
|
||||||
|
<height>417</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Raindar</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Utrecht,the Netherlands</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>images/arrow-circle-225.png</normaloff>images/arrow-circle-225.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="weatherIcon">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="weatherLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QLabel" name="forecastIcon4">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="forecastTemp2">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QLabel" name="forecastTemp5">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QLabel" name="forecastTemp4">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="forecastIcon2">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QLabel" name="forecastIcon5">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="forecastIcon1">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QLabel" name="forecastIcon3">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="baseSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QLabel" name="forecastTemp3">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="forecastTemp1">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="forecastTime1">
|
||||||
|
<property name="text">
|
||||||
|
<string>+3h</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="forecastTime2">
|
||||||
|
<property name="text">
|
||||||
|
<string>+6h</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="forecastTime3">
|
||||||
|
<property name="text">
|
||||||
|
<string>+9h</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="forecastTime4">
|
||||||
|
<property name="text">
|
||||||
|
<string>+12h</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QLabel" name="forecastTime5">
|
||||||
|
<property name="text">
|
||||||
|
<string>+15h</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Barometer</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Temperature</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="temperatureLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Humidity</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="humidityLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pressure</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="pressureLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Location</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Longitude</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="1">
|
||||||
|
<widget class="QLabel" name="longitudeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Latitude</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<widget class="QLabel" name="latitudeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sunrise</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QLabel" name="sunriseLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Speed</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Wind</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="windLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
94
weather/weather.py
Normal file
@ -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_()
|