App module

The main app and GUI.

The GUI is organized in “pages” with various functions. Actual calculations and other functionality is handled by imported modules.

Sources:

This code uses some concepts and code-passages from other authors:

Frame Switching

Menubar Switching

class App.App

Bases: tkinter.Tk

The main class that starts the app and keeps it running.

In this class, the frames are created, as well as the functions to switch between them.

__init__()

Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will be created. BASENAME will be used for the identification of the profile file (see readprofile). It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME is the name of the widget class.

frames

List of all used frames. They’re NOT strings but actual classes. Any new frame-class created must be added to this list!

Type

list of classes

show_frame(page_name)

Calls up any frame in the dictionary.

Parameters

page_name (str) – The name of the frame class to be raised.

class App.AstrolabePage(location, controller)

Bases: tkinter.Frame

User Map Page

Where user map and star maps are compared.

Parameters
  • location (tk.Frame) – “Master”-Frame into which the frame is loaded.

  • controller (class) – Controller-class in which the frame-switching function is defined.

__init__(location, controller)

Construct a frame widget with the parent MASTER.

Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.

c_background

Background color of the frame.

c_button

Background color of the buttons

c_label

Text color of the labels

c_text

Text color of the buttons

calculate_astrolabe()

Starts the comparison calculations

All chosen parameters are passen to the Astrolabe-class for use.

choose_map()

Lets the user load a star map and sets the corresponding bool to true.

choose_pattern()

Lets the user load a pattern file and sets the corresponding bool to true.

commence()

A separate “commence” function is needed to check conditions and intialize threading

menubar(root)

Defines the menu bar. Is repeated accordingly on other pages.

Returns

Returns a tk-object because function does not draw menubar itself. Drawing happens in App-class.

Return type

tk.Menu

class App.StarMapPage(location, controller)

Bases: tkinter.Frame

User Map Page

Where users input their own pattern.

Parameters
  • location (tk.Frame) – “Master”-Frame into which the frame is loaded.

  • controller (class) – Controller-class in which the frame-switching function is defined.

__init__(location, controller)

Construct a frame widget with the parent MASTER.

Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.

c_background

Background color of the frame.

c_button

Background color of the buttons

c_label

Text color of the labels

c_text

Text color of the buttons

calculate_atlas()

Calculating the “Atlas”

Commences calculations and creates as many maps as chosen by the user.

commence()

A separate “commence” function is needed to check conditions and intialize threading

menubar(root)

Defines the menu bar. Is repeated accordingly on other pages.

Returns

Returns a tk-object because function does not draw menubar itself. Drawing happens in App-class.

Return type

tk.Menu

update_end(val)

Timeframe sanity check

update_start and update_end functions are needed to adjust the BP-sliders in real time and make sure only logical conditions can be set.

Parameters

val (int) – Current value of the slider.

update_start(val)

Timeframe sanity check

update_start and update_end functions are needed to adjust the BP-sliders in real time and make sure only logical conditions can be set.

Parameters

val (int) – Current value of the slider.

validate_latitude(input)

Validate latitude

Real-time validation of the input field for the latitude. Makes sure that neither non-numeric characters nor values over 90 can be entered.

validate_neighbors(input)

Validate number of neighbors

Real-time validation of the input field for the neighbors. Makes sure that neither non-numeric characters nor values over 5000 can be entered.

class App.StartPage(location, controller)

Bases: tkinter.Frame

The frame that is displayed by default as soon as the app is run.

Parameters
  • location (tk.Frame) – “Master”-Frame into which the frame is loaded.

  • controller (class) – Controller-class in which the frame-switching function is defined.

__init__(location, controller)

Construct a frame widget with the parent MASTER.

Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.

c_background

Background color of the frame.

c_button

Background color of the buttons

c_label

Text color of the labels

menubar(root)

Defines the menu bar. Is repeated accordingly on other pages.

Returns

Returns a tk-object because function does not draw menubar itself. Drawing happens in App-class.

Return type

tk.Menu

class App.UserMapPage(location, controller)

Bases: tkinter.Frame

User Map Page

Where users input their own pattern.

Parameters
  • location (tk.Frame) – “Master”-Frame into which the frame is loaded.

  • controller (class) – Controller-class in which the frame-switching function is defined.

__init__(location, controller)

Construct a frame widget with the parent MASTER.

Valid resource names: background, bd, bg, borderwidth, class, colormap, container, cursor, height, highlightbackground, highlightcolor, highlightthickness, relief, takefocus, visual, width.

c_background

Background color of the frame.

c_button

Background color of the buttons

c_label

Text color of the labels

c_text

Text color of the buttons

import_image()

Function to import and automatically resize reference images.

load_pattern()

Loads a saved pattern along with its corresponding reference image.

menubar(root)

Defines the menu bar. Is repeated accordingly on other pages.

Returns

Returns a tk-object because function does not draw menubar itself. Drawing happens in App-class.

Return type

tk.Menu

save_pattern()

Saves the pattern and the corresponding image.