_clockalarm package

Submodules

_clockalarm.Alert module

class _clockalarm.Alert.Alert(trigger_time)[source]

Bases: PyQt5.QtCore.QObject

Abstract Alert class representing alerts.

trigger_time

The trigger time of the alert.

id

The identification number of the alert in the alert.

Set up when added to the database.
get_id()[source]

Get the Alert identifier.

Returns:The identifier of the alert.
get_trigger_time()[source]

Get the Alert trigger time in seconds since epoch.

Returns:The trigger time
timeout
triggered()[source]

Triggers the alert action.

class _clockalarm.Alert.AlertMeta[source]

Bases: sip.wrappertype, abc.ABC

Abstract Metaclass inheriting QObject’s metaclass

_clockalarm.AlertCollection module

class _clockalarm.AlertCollection.AlertCollection(parent=None)[source]

Bases: object

Collection of all the Alert objects running on the program.

This class contains utilities to load, update and save the alerts in a TinyDB database, and maintain the correct state of all the alerts

add(alert: _clockalarm.SimpleAlert.SimpleAlert)[source]

Add the Alert given in argument to the collection of alerts

If parent is set, the new Alert is connected to the notification center and the list of displayed alerts is updated.

alert

SimpleAlert – The alert to add to the collection

Exceptions:
ValueError: If the alert argument is None or incorrect.
check_timers(trig_time)[source]

Check all the alerts to see if on should be triggered

This function is triggered periodically by the clock.

trig_time

Actual time, in seconds.

clean_db()[source]

Make the TinyDB database consistent

All the outdated alerts without periodicity are removed. New trigger time is calculated for outdated alerts with periodicity.

If the db is corrupted, nothing append.

delete(id_alert: int)[source]

Remove an alert from the collection

id_alert

The id number of the alert to remove.

Exceptions:
KeyError: If the alert to delete doesn’t exist in the database.
display()[source]

Actualize the UI alert list display

If parent is unset, the AlertCollection object isn’t link to any QWindow and nothing append

edit(id_alert: int, notification: _clockalarm.Notification.Notification = None, trigger_time: int = None, periodicity: int = None)[source]

Update an alert with the given modifications

If the trigger_time is in the past, he won’t re updated.

id_alert

int – The id number of the alert to modify

notification

Notification, optional – Default is None. The new notification

trigger_time

int,optional – Default is None. The new trigger time

periodicity(int,optional

Default is None. The new periodicity

Exceptions:
KeyError: If the alert to edit doesn’t exist in the database. ValueError: If the periodicity argument is under zero.
load_db()[source]

Fill the AlertCollection with Alerts form the TinyDB database

Exceptions:
IOError: If a required parameter can’t be found in the database. The database is probably corrupted.

_clockalarm.Clock module

class _clockalarm.Clock.Clock(frequency, parent=None)[source]

Bases: PyQt5.QtCore.QThread

Clock emitting ticks with a given periodicity.

The class extends QThread to allow threading.

frequency

The frequency at which the clock emits a tick.

parent

The parent. Default value is None.

run()[source]

Start the clock.

stop()[source]

Stop the clock.

tick

_clockalarm.Notification module

class _clockalarm.Notification.Notification(message: str, color_hex: str = None, font_family: str = None, font_size: int = None, sound: str = None)[source]

Bases: object

Encapsulate the parameters of a Notification in order to pass it to the NotificationCenter

get_color()[source]

Build a QColor from color_hex parameter

If color_hex parameter is missing, replace it with de default configuration.

Returns:The QColor of the notification
get_font()[source]

Build a QFont from font_family and font_size

If font_family or font_size parameter is missing, replace it with de default configuration.

Returns:The QFont of the notification
get_message()[source]

Getter for message

Returns:The notification text
get_sound()[source]

Build a mixer.Sound object from sound parameter

If the sound path parameter is missing, replace it with de default configuration.

Returns:The mixer.Sound file of the notification

_clockalarm.NotificationCenter module

class _clockalarm.NotificationCenter.NotificationCenter(screen_geometry, parent=None)[source]

Bases: object

Class handling the display of the Notification Widgets

Receives the notifications to display and add it to a queue. If there is free slot on the UI display area, pop the queue and display the notification. If the user clicks on the widget, closes it and compacts the remaining widgets.

add_to_queue(notification)[source]

Add a new notification to the queue

The notification will wait till there is a free spot in the display zone

notification

Notification – The notification to add to enqueue

Exceptions:
ValueError: If the user try to add None or incorrect Notification object to the queue
close_popup(popup: _clockalarm.UI.NotificationWidget.NotificationWidget)[source]

Triggered by a NotificationWidget when closed

Remove the popup from the list and refresh the display zone.

popup

The NotificationWidget to remove from the display zone

Exceptions:
ValueError: If the user pass a None or incorrect popup object as argument. KeyError: If the popup isn’t in the list and can’t be removed
display_popup(geom: PyQt5.QtCore.QRect, notification)[source]

Display a QWidget popup

Play a sound if the program isn’t muted

geom

QRect – position and size of the widget on the screen

notification

Notification – the notification to display

Exceptions:
ValueError: In case of None or invalid QRect object as geom argument ValueError: In case of None or invalid Notification object as notification argument IndexError: If the number of displayed popups is greater or equal to the max number of displayed popups
refresh()[source]

Refresh the display off notifications in the display zone

Compact the remaining notifications in the display zone, if there is free slots, pop the notification queue and display the popup.

_clockalarm.SimpleAlert module

class _clockalarm.SimpleAlert.SimpleAlert(trigger_time, notification, periodicity=None)[source]

Bases: _clockalarm.Alert.Alert

Simple Alert implementation with text message

trigger_time

The time at which the alert is triggered.

notification

The notification to display when the alert is triggered.

periodicity

frequency in which the alert is displayed, in seconds.

get_notification()[source]

Get the Notification

Returns:The Notification of the Alert
get_periodicity()[source]

Get the SimpleAlert periodicity

Returns:The periodicity
triggered()[source]

This method does the same as triggered()

_clockalarm.main module

class _clockalarm.main.App(default_config_path, alert_db_path, *argv)[source]

Bases: PyQt5.QtWidgets.QApplication

Main Application extending QApplication

CLOCK_FREQUENCY = None
MUTE = None
init_alert_collection()[source]

Init AlertCollection object and connect the clock to it

Note

The alerts will be loaded from the default database

init_clock(freq)[source]

Init and start the Clock with the given frequency

freq

frequency of the clock’s ticks

init_config()[source]

Open the config_test.cfg file and use a parser to retrieve default values

init_ui()[source]

Initialisation of the main window GUI

_clockalarm.main.main(argv)[source]

Main function called when application starts

_clockalarm.main.argv

optional – path of the config file and the alertDB file usage: program configFile alrtDBFile If no argument entered, default is config_test.cfg and alertDB.json

Returns:the system exit code

Module contents