gui package


gui.conf module

Provides ConfigFrame, the Tkinter frame that allows modifying the visualiser configuration

class gui.conf.ConfigFrame(root, main)[source]

Bases: tkinter.Frame

Frame allowing the configuration of the visualiser

Contains a number of Tkinter controls allowing the modification of attributes in SimulatorConfig

_labelControl(text, control, ctrlOpts={})[source]

Create a label and a widget, which are placed adjacent on the same row.

  • textstr to show in the label
  • controlobject class of the control to create
  • ctrlOptsdict of kwargs to use when constructing the control.

The created Widget control


Load values into the controls from the SimulatorConfig

_matches = {'CarScale': 'carScale', 'CarSpeed': 'carSpeed', 'ObstacleInterval': 'obstFreq', 'ObstacleSpeed': 'obstSpeed'}

SimulatorConfig attributes as keys, associated private attributes (with a set() method) as attributes. These config values are all float


Save values into the SimulatorConfig from the controls

gui.controls module

Provides custom Tkinter controls

class gui.controls.LabeledScale(root, font, resolution=2, **kwargs)[source]

Bases: tkinter.Frame

tkinter.ttk.Scale and a tkinter.Spinbox joined in a frame

The Scale in shown to the left of the Spinbox

  • root – Parent tkinter.Widget
  • fontFont to use in the Spinbox
  • resolution – (int) Number of decimal places to round stored and displayed value to

Callback method for both the Spinbox and Scale so that each can update the other, and the value can be properly formatted

Returns:float - Value stored, rounded to specified resolution number of decimal places

Set value of both the Spinner and Scale

Parameters:valfloat to set values to
class gui.controls.ToolTip(widget, text='', delay=500, width=250)[source]

Bases: object

Creates a tooltip that appears above the given widget when hovered

  • widgettkinter.Widget to bind to
  • text – (str) Text content of the tooltip
  • delay – (int) Milliseconds before displaying tooltip on hover
  • width – (int) Maximum width of tooltip in characters

gui.main module

The main window and main page which links to the others

class gui.main.MainFrame(root, main)[source]

Bases: tkinter.Frame

Main ‘page’ of the application, linking to the Simulator and ConfigFrame using Button widgets. These cause the MainWindow to focus on the desired frame

class gui.main.MainWindow(*args, **kwargs)[source]

Bases: tkinter.Tk

The main Tkinter window of the application

Encapsulates Simulator and ConfigFrame


Tkinter key press callback method, sends events to the Simulator if it is currently focused


The encapsulated Simulator

Getter:Get the simulator

Run tick() on the Simulator

Repeatedly calls itself in intervals of TickRate milliseconds while the Simulator window remains focused


Return to the main menu by raising the MainFrame to the top


Focus on a specified contained frame. Starts the tick cycle by calling _tick() if focusing on the Simulator


(str) Class name of the encapsulated frame that should be focused

One of ‘MainFrame’, ‘ConfigFrame’

gui.panel module

Provides the side panel shown alongside the visulaiser

class gui.panel.SimulatorPanel(parent, sim, visualiser, **kwargs)[source]

Bases: tkinter.Frame

Side panel of the window, extends tk.Frame. Shows information about the visulisation.

  • parent – Parent tkinter.Widget
  • simSimulator instance to control
  • visualiserSimulatorVisualiser instance to take information from
  • kwargs – keyword arguments to pass to superclass constructor

Return a function that focuses the panel then calls func

Used for button commands

_makeLabel(name, text, row)[source]

Create and attach multiple labels to the given row

  • namestr used in property names
  • textstr to use as label
  • rowtkinter.Widget to attach to

Create a new row to be used

Returns:The new Frame

Update displayed information using the SimulatorVisualiser

gui.sim module

Provides the main simulator, which includes the Pygame visualiser and a Tkinter panel

class gui.sim.NameDatasetPopup(main)[source]

Bases: tkinter.Toplevel

A Tkinter popup that requests a name for a training set.

It will check if the name is in use; if it is, another prompt asks whether it should be overriden or another name should be input.


Close the popup and set the input value on the Simulator

class gui.sim.Simulator(root, main)[source]

Bases: tkinter.Frame

The GUI component of the visualiser Contains the SimulatorVisualiser (Pygame canvas) in a

tkinter.ttk.Frame. The SimulatorPanel is displayed alongside it.


Stop the visualiser and return to the main menu


If loaded in manual mode, create a NameDatasetPopup to choose the training data name.

If in AUDRI mode, train the model


Pass key press events to visualiser

The current mode in which the simulator should run in.
0 = Manual: Collect training data
1 = AUDRI: Train AUDRI and let it control the car
2 = Compare: Allow both expert and AUDRI to control two different cars, side by side
Getter:Get the current mode
Setter:Set the current mode, also setting the mode of the SimulatorVisualiser. Prevents setting an invalid mode

Reset random seed and restart visualiser using reset()


Set the _datasetName property from the NameDatasetPopup, unpause the SimulatorVisualiser, and return focus to the main window

Parameters:namestr name of dataset to store training data in

Call visualiser and panel tick frequently