GWeather.Info

g GObject.Object GObject.Object GWeather.Info GWeather.Info GObject.Object->GWeather.Info

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (location)

class

store_cache ()

abort ()

get_apparent ()

get_application_id ()

get_attribution ()

get_conditions ()

get_contact_info ()

get_dew ()

get_enabled_providers ()

get_forecast_list ()

get_humidity ()

get_icon_name ()

get_location ()

get_location_name ()

get_pressure ()

get_sky ()

get_sunrise ()

get_sunset ()

get_symbolic_icon_name ()

get_temp ()

get_temp_max ()

get_temp_min ()

get_temp_summary ()

get_upcoming_moonphases (phases)

get_update ()

get_value_apparent (unit)

get_value_conditions ()

get_value_dew (unit)

get_value_moonphase ()

get_value_pressure (unit)

get_value_sky ()

get_value_sunrise ()

get_value_sunset ()

get_value_temp (unit)

get_value_temp_max (unit)

get_value_temp_min (unit)

get_value_update ()

get_value_visibility (unit)

get_value_wind (unit)

get_visibility ()

get_weather_summary ()

get_wind ()

is_daytime ()

is_valid ()

network_error ()

next_sun_event ()

set_application_id (application_id)

set_contact_info (contact_info)

set_enabled_providers (providers)

set_location (location)

update ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

application-id

str

r/w

An unique reverse-DNS application ID

contact-info

str

r/w

An email address or contact form URL

enabled-providers

GWeather.Provider

r/w

A bitmask of enabled weather service providers

location

GWeather.Location

r/w/c

The location this info represents

Signals

Inherited:

GObject.Object (1)

Name

Short Description

updated

This signal is emitted after the initial fetch of the weather data from upstream services, and after every successful call to [method`GWeather`.Info.update].

Fields

Inherited:

GObject.Object (1)

Class Details

class GWeather.Info(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GWeather.InfoClass

GWeatherInfo provides a handy way to access weather conditions and forecasts from a [class`GWeather`.Location], aggregating multiple different web services.

It includes also astronomical data such as sunrise times and moon phases.

classmethod new(location)
Parameters:

location (GWeather.Location or None) – the desidered location

Returns:

a new weather information instance

Return type:

GWeather.Info

Builds a new GWeatherInfo that will provide weather information about the given location.

In order to retrieve the weather information, you will need to enable the desired providers and then call [method`GWeather`.Info.update]. If you want to be notified of the completion of the weather information update, you should connect to the [signal`GWeather`.Info::updated] signal before updating the GWeatherInfo instance.

classmethod store_cache()

Ensures that any data cached from the network is stored to disk. Calling this is not necessary, as the cache will be saved when the last reference to a GWeather.Info will be dropped. On the other hand, it must be called if there is any chance that the application will be closed without unreffing all objects, such as when using a language binding that employs a GC.

abort()
get_apparent()
Return type:

str

get_application_id()
Returns:

the application ID

Return type:

str

Get the application ID of the application fetching the weather.

get_attribution()
Returns:

the required attribution text, in Pango markup form, or None if not required

Return type:

str

Some weather services require the application showing the data to include an attribution text, possibly including links to the service website. This must be shown prominently toghether with the data.

get_conditions()
Return type:

str

get_contact_info()
Returns:

the contact information

Return type:

str

Get the contact information of the application fetching the weather.

get_dew()
Return type:

str

get_enabled_providers()
Return type:

GWeather.Provider

Gets the bitmask of enabled GWeather.Provider weather providers.

get_forecast_list()
Returns:

list of GWeather.Info objects for the forecast. The list is owned by the ‘info’ object thus is alive as long as the ‘info’. The ‘update’ property is the date/time when the forecast info is used for.

Return type:

[GWeather.Info]

get_humidity()
Return type:

str

get_icon_name()
Return type:

str

get_location()
Return type:

GWeather.Location

get_location_name()
Return type:

str

get_pressure()
Return type:

str

get_sky()
Return type:

str

get_sunrise()
Return type:

str

get_sunset()
Return type:

str

get_symbolic_icon_name()
Return type:

str

get_temp()
Return type:

str

get_temp_max()
Return type:

str

get_temp_min()
Return type:

str

get_temp_summary()
Return type:

str

get_upcoming_moonphases(phases)
Parameters:

phases (int) –

Return type:

bool

get_update()
Return type:

str

get_value_apparent(unit)
Parameters:

unit (GWeather.TemperatureUnit) – the desired unit, as a GWeather.TemperatureUnit

Returns:

True is value is valid, False otherwise.

value:

the apparent temperature

Return type:

(bool, value: float)

get_value_conditions()
Returns:

True is out arguments are valid, False otherwise.

phenomenon:

a location for a GWeather.ConditionPhenomenon.

qualifier:

a location for a GWeather.ConditionQualifier.

Return type:

(bool, phenomenon: GWeather.ConditionPhenomenon, qualifier: GWeather.ConditionQualifier)

Fills out phenomenon and qualifier with current weather conditions.

get_value_dew(unit)
Parameters:

unit (GWeather.TemperatureUnit) – the desired unit, as a GWeather.TemperatureUnit

Returns:

True is value is valid, False otherwise.

value:

the dew point

Return type:

(bool, value: float)

get_value_moonphase()
Returns:

True is value is valid, False otherwise.

value:

the current moon phase

lat:

the moon declension

Return type:

(bool, value: float, lat: float)

get_value_pressure(unit)
Parameters:

unit (GWeather.PressureUnit) – the desired unit, as a GWeather.PressureUnit

Returns:

True if value is valid, False otherwise.

value:

forecasted pressure, expressed in unit

Return type:

(bool, value: float)

get_value_sky()
Returns:

True is sky is valid, False otherwise.

sky:

a location for a GWeather.Sky.

Return type:

(bool, sky: GWeather.Sky)

Fills out sky with current sky conditions.

get_value_sunrise()
Returns:

True is value is valid, False otherwise.

value:

the time of sunrise

Return type:

(bool, value: int)

get_value_sunset()
Returns:

True is value is valid, False otherwise.

value:

the time of sunset

Return type:

(bool, value: int)

get_value_temp(unit)
Parameters:

unit (GWeather.TemperatureUnit) – the desired unit, as a GWeather.TemperatureUnit

Returns:

True is value is valid, False otherwise.

value:

the temperature value

Return type:

(bool, value: float)

get_value_temp_max(unit)
Parameters:

unit (GWeather.TemperatureUnit) – the desired unit, as a GWeather.TemperatureUnit

Returns:

True is value is valid, False otherwise.

value:

the maximum temperature value

Return type:

(bool, value: float)

get_value_temp_min(unit)
Parameters:

unit (GWeather.TemperatureUnit) – the desired unit, as a GWeather.TemperatureUnit

Returns:

True is value is valid, False otherwise.

value:

the minimum temperature value

Return type:

(bool, value: float)

get_value_update()
Returns:

True is value is valid, False otherwise.

value:

the time self was last updated

Return type:

(bool, value: int)

Note that value may be 0 if self has not yet been updated.

get_value_visibility(unit)
Parameters:

unit (GWeather.DistanceUnit) – the desired unit, as a GWeather.DistanceUnit

Returns:

True if value is valid, False otherwise.

value:

forecasted visibility, expressed in unit

Return type:

(bool, value: float)

get_value_wind(unit)
Parameters:

unit (GWeather.SpeedUnit) – the desired unit, as a GWeather.SpeedUnit

Returns:

True if speed and direction are valid, False otherwise.

speed:

forecasted wind speed

direction:

forecasted wind direction

Return type:

(bool, speed: float, direction: GWeather.WindDirection)

get_visibility()
Return type:

str

get_weather_summary()
Returns:

a summary for current weather conditions.

Return type:

str

get_wind()
Return type:

str

is_daytime()
Returns:

Whether it is daytime (that is, if the sun is visible) or not at the location and the point of time referred by self. This is mostly equivalent to comparing the return value of GWeather.Info.get_value_sunrise() and GWeather.Info.get_value_sunset(), but it accounts also for midnight sun and polar night, for locations within the Artic and Antartic circles.

Return type:

bool

is_valid()
Return type:

bool

network_error()
Return type:

bool

next_sun_event()
Return type:

int

set_application_id(application_id)
Parameters:

application_id (str) – the application ID to set

Sets the application ID of the application fetching the weather. It is a requirement for using any of the online weather providers.

If the application uses Gio.Application, then the application ID will be automatically filled in.

set_contact_info(contact_info)
Parameters:

contact_info (str) – the contact information for the application

Sets the contact information for the application fetching the weather. It is a requirement for using any of the online weather providers as it allows API providers to contact application developers in case of terms of use breaches.

The contact information should be an email address, or the full URL to an online contact form which weather providers can use to contact the application developer. Avoid using bug tracker URLs which require creating accounts.

set_enabled_providers(providers)
Parameters:

providers (GWeather.Provider) – a bitmask of GWeather.Provider

Sets the enabled providers for fetching the weather. Note that it is up to the application developer to make sure that the terms of use for each service are respected.

Online providers will not be enabled if the application ID is not set to a valid value.

set_location(location)
Parameters:

location (GWeather.Location or None) – a location for which weather is desired

Changes the location of the weather report.

Note that this will clear any forecast or current conditions, and you must call [method`GWeather`.Info.update] to obtain the new data.

update()

Requests a reload of weather conditions and forecast data from enabled network services. This call does no synchronous IO: rather, the result is delivered by emitting the GWeather.Info ::updated signal. Note that if no network services are enabled, the signal will not be emitted. See GWeather.Info :enabled-providers for details.

Signal Details

GWeather.Info.signals.updated(info)
Signal Name:

updated

Flags:

RUN_FIRST

Parameters:

info (GWeather.Info) – The object which received the signal

This signal is emitted after the initial fetch of the weather data from upstream services, and after every successful call to [method`GWeather`.Info.update].

Property Details

GWeather.Info.props.application_id
Name:

application-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

A unique identifier, typically in the form of reverse DNS notation, for the application that is querying the weather information.

Weather providers require this information.

GWeather.Info.props.contact_info
Name:

contact-info

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

An email address or any other contact form URL.

Weather providers require this information.

GWeather.Info.props.enabled_providers
Name:

enabled-providers

Type:

GWeather.Provider

Default Value:

GWeather.Provider.NONE

Flags:

READABLE, WRITABLE

The enabled weather providers.

GWeather.Info.props.location
Name:

location

Type:

GWeather.Location

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

The location of the weather information.