Welcome to Binary Clock Software’s documentation!

Binary Clock Python API

API functions for interfacing with the Binary Clock

BinaryClockAPI Class

class binaryClockAPI.BinaryClockAPI(serial_port, baud=250000)[source]

Main class that handles communication and exposes functions to be called.

Parameters:
  • serial_port (str) – Serial port to connect to. (e.g. “/dev/tty.usbserial-12345”)
  • baud (int) – baudrate to communicate at (default: 250000)
clear_LED(row, column)[source]

Clear an LED at the given co-ordinates.

Parameters:
  • row (int) – Row of the LED to clear
  • column (int) – Column of the LED to clear
clear_all_LEDs()[source]

Clears all LEDs.

close()[source]

Closes the com port to the device

set_LED(row, column, red, green, blue)[source]

Set an LED to the given color.

Parameters:
  • row (int) – Row of the LED to set
  • column (int) – Column of the LED to set
  • red (int) – Red value (0 - 255)
  • green (int) – Green value (0 - 255)
  • blue (int) – Blue value (0 - 255)
set_all_LEDs(red, green, blue)[source]

Sets all LEDs to the given color.

Parameters:
  • red (int) – Red value (0 - 255)
  • green (int) – Green value (0 - 255)
  • blue (int) – Blue value (0 - 255)
set_color(red, green, blue)[source]

Sets the active colors when running in time mode.

Parameters:
  • red (int) – Red value (0 - 255)
  • green (int) – Green value (0 - 255)
  • blue (int) – Blue value (0 - 255)
set_state(state)[source]

Sets the current state of the device. (either time control or manual control)

Parameters:state (int) – Can either be 0 (RUN TIME) or 1 (RUN MANUAL)
update_time(time_override_arr=None)[source]

Function for updating the time displayed on the clock. By default, uses time.localtime() function to grab the current time from your computer.

Parameters:time_override_arr (list) – List (in the format [hour, min, sec]) if you want to override the local time on your machine.

Binary Clock GUI

GUI for the Binary Clock API.

BinaryClockGUI Class

class binaryClockGUI.BinaryClockGUI[source]

Binary Clock GUI Object

clear_LED()[source]

Clears an individual LED.

clear_all_LEDs()[source]

Clears all LEDs.

connect()[source]

Connect with the binary clock. (basically just opens serial communication)

disconnect(raise_error_dialog=True)[source]

Disconnect the binary clock by closing communication, deleting the binaryClock object, and resetting the GUI elements to the disconnected state.

on_closing()[source]

Asks user if they really want to close, then destroys the window.

run()[source]

Runs the tk loop.

set_LED()[source]

Sets an individual LED.

set_all_LEDs()[source]

Sets all LEDs to a color.

set_time()[source]

Sets the binary clock time.

time_override(*args)[source]

activates and deactivates the time override boxes (hour, minute, and second) when the time override checkbox is toggled.

update_color()[source]

Updates the color that is displayed when time is running.

update_coms_list(*args)[source]

Update the list of serial ports when the coms list dropdown is clicked.

GUI Helper Functions

Custom wrappers around Tkinter classes & functions.

CheckBox Class

class CustomGUIWrappers.CheckBox(master, row, column, callback_funct=None, cb_text=”, padx=3, pady=3, columnspan=1)[source]

Class for creating a checkbox. Used when you need a boolean decision from the user.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the check box is put into.
  • column (int) – what column the check box is put into.
  • true_callback_funct (funct) – This function is called when the box is checked by the user.
  • false_callback_funct (funct) – This function is called when the box is unchecked by the user.
  • cb_text (str) – this is the label for the check box. [default: “”]
  • padx (int) – This is how much x axis padding is given to the check box. [default: 3 px]
  • pady (int) – This is how much y axis padding is given to the check box. [default: 3 px]
activate()[source]

Activates the check box to allow the user to change it’s value.

cb()[source]

This function is called when the check box changes state. if it is checked, it calls self.true_callback_funct(). if it is unchecked, it calls self.false_callback_funct()

deactivate()[source]

Deactivates the check box to prevent the user from changing it’s value.

get_val()[source]

Returns the current value of the check box.

EntryBox Class

class CustomGUIWrappers.EntryBox(master, row, column, default_val=”, **kwargs)[source]

Class for creating an Entry box. Used when you need a string input from the user.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the entry box is put into.
  • column (int) – what column the entry box is put into.
  • default_val (str) – String that first populates the box. [default: “”]
  • **padx (int) – This is how much x axis padding is given to the entry box. [default: 3 px]
  • **pady (int) – This is how much y axis padding is given to the entry box. [default: 3 px]
  • **box_width (int) – Sets how wide the input box is [default: 20 px]
  • **state (str) – Sets the state of the entry box (disabled, readonly, etc.) [default: “active”]
  • **sticky – Sets which side of the cell the Entry box sticks to. (e.g. tk.E) [default: “”]
  • **justify – Sets how the text in the Entry box aligns. [default: tk.LEFT]
activate()[source]

Activates the entry box to allow the user to change it’s value.

deactivate()[source]

Deactivates the entry box to prevent the user from changing it’s value.

focus()[source]

Moves the user’s cursor to this box.

forget()[source]

Removes the label from the GUI temporarily.

get_val()[source]

Returns the current value of the Entry box.

remember()[source]

Brings the label back into view.

Labels Class

class CustomGUIWrappers.Labels(master, row, column, label, **kwargs)[source]

Class for the various labels in the GUI. useful so we can forget & remember them when we need them to be invisable or visable, respectively.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the label is put into.
  • column (int) – what column the label is put into.
  • default_val (str) – String that first populates the box. [default: “”]
  • **padx (int) – This is how much x axis padding is given to the check box. [default: 3 px]
  • **pady (int) – This is how much y axis padding is given to the check box. [default: 0 px]
  • **columnspan (int) – Sets how many columns the label spans. [default: 1]
  • **sticky (int) – Sets where the dropdown box populates in it’s cell. [default: None]
config(state)[source]

configures the label. used for changing between DISABLED and NORMAL states.

forget()[source]

Removes the label from the GUI temporarily.

remember()[source]

Brings the label back into view.

ScrollBox Class

class CustomGUIWrappers.ScrollBox(master, row, column, min_val, max_val, start_val, **kwargs)[source]

Class for creating a scroll box. Used when you need an integer input from the user in a certain range.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the check box is put into.
  • column (int) – what column the check box is put into.
  • min_val (int) – Minimum value that the Scroll box can be.
  • max_val (int) – Maximum value that the Scroll box can be.
  • start_val (int) – Initial value of the box.
  • **padx (int) – This is how much x axis padding is given to the check box. [default: 3 px]
  • **pady (int) – This is how much y axis padding is given to the check box. [default: 3 px]
  • **box_width (int) – Sets how wide the input box is [default: 19 px]
_backspace(entry)[source]

Removes the most recently entered character.

_e_check(e)[source]

Checks for an erronious input.

_validate(e)[source]

Checks all of the values for proper ranges.

activate()[source]

Activates the Scroll box to allow the user to change it’s value.

deactivate()[source]

Deactivates the Scroll box to prevent the user from changing it’s value.

get_val()[source]

Returns the current value of the Scroll box.

set_val(value)[source]

Sets the current value of the Scroll box.

Button Class

class CustomGUIWrappers.Button(master, row, column, callback, label, **kwargs)[source]

Class for creating an Entry box. Used when you need a string input from the user.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the check box is put into.
  • column (int) – what column the check box is put into.
  • min_val (int) – Minimum value that the Scroll box can be.
  • max_val (int) – Maximum value that the Scroll box can be.
  • start_val (int) – Initial value of the box.
  • **padx (int) – This is how much x axis padding is given to the check box. [default: 3 px]
  • **pady (int) – This is how much y axis padding is given to the check box. [default: 3 px]
  • **columnspan (int) – Sets how many columns the label spans. [default: 1]
  • **sticky (int) – Sets where the dropdown box populates in it’s cell. [default: None]
activate()[source]

Activates the button to allow the user to change it’s state.

deactivate()[source]

Deactivates the button to prevent the user from changing it’s state.

TimeEntry Class

class CustomGUIWrappers.TimeEntry(master, row, column, padx=3, pady=3, default_val_dict={‘second’: 42, ’minute’: 30, ’hour’: 12})[source]

Class for creating a time enry box. Used when you need a time input from the user.

Parameters:
  • master – This is the root variable of the GUI. (tk.TK())
  • row (int) – what row the check box is put into.
  • column (int) – what column the check box is put into.
  • default_val_dict (dict) – Dictionary of values that first populates the boxes. [default: {“hour”: 12, “minute”: 30, “second”: 42}]
  • padx (int) – This is how much x axis padding is given to the check box. [default: 3 px]
  • pady (int) – This is how much y axis padding is given to the check box. [default: 3 px]
  • box_width (int) – Sets how wide the input box is [default: 20 px]
_backspace(entry)[source]

called when we need to delete the most recent character.

_err_hour_check(e)[source]

Error checking function for the third box (the hours category).

_err_min_check(e)[source]

Error checking function for the second box (the minutes category).

_err_sec_check(e)[source]

Error checking function for the first box (the seconds category).

activate()[source]

Activates all input boxes.

deactivate()[source]

Deactivates all input boxes.

get_val()[source]

Gets the value input by the user.

Returns dict:Time input by user. Valid keys: hour, minute, second.

Indices and tables