def __init__(self): super(LocalityWidGet, self).__init__() self.setWindowTitle = 'Settings' self.setGeometry(450, 300, 400, 200) self.locality_label = QLabel('Localidade: ',self) self.locality_label.move(20, 35) self.locality_label_example = QLabel('Exemplo: Porto Alegre, RS', self) self.locality_label_example.move(100, 60) self.locality_input_text = QLineEdit(self) self.locality_input_text.move(100, 30) wc = WeatherClient() current_locality = wc.get_place() self.locality_input_text.setText(current_locality.replace('+', ', ').decode('utf-8')) self.btnOk = QPushButton('OK', self) self.btnOk.move(250, 150) self.btnOk.clicked.connect(lambda: Eventer.save_new_locality(self)) self.show()
def show_weather_forecast_message(tray): wc = WeatherClient() forecast, temperature = wc.reload_weather_info() ico = weather_consts.weather_types.get(forecast) if ico: tray.setIcon(QIcon.fromTheme()) tray.showMessage('Tempo agora:', (temperature + '°C ' + forecast).decode('utf-8'))
def save_new_locality(widget): locality_text = widget.locality_input_text.getText() locality_text = locality_text.split(',') if len(locality_text) > 0: wc = WeatherClient() wc.set_place(locality_text[0].strip(),\ locality_text[1].strip() if len(locality_text) > 1 else '') widget.close()
def test_response(self): client = WeatherClient() self.assertEquals(client.get_weather(), "Nice, but a little cloudy.")