gui package

Submodules

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.

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

The created Widget control

_load()[source]

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()[source]

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

Parameters:
  • root – Parent tkinter.Widget
  • fontFont to use in the Spinbox
  • resolution – (int) Number of decimal places to round stored and displayed value to
_update(val=None)[source]

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

get()[source]
Returns:float - Value stored, rounded to specified resolution number of decimal places
set(val)[source]

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

Authors:
Parameters:
  • 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
_cursorPos(widget)[source]
_enter(event=None)[source]
_hide()[source]
_leave(event=None)[source]
_schedule()[source]
_show(event=None)[source]
_unschedule()[source]

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

Parameters:
startSim(mode)[source]
class gui.main.MainWindow(*args, **kwargs)[source]

Bases: tkinter.Tk

The main Tkinter window of the application

Encapsulates Simulator and ConfigFrame

_keyPress(event)[source]

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

_simulator

The encapsulated Simulator

Getter:Get the simulator
Type:Widget
_tick()[source]

Run tick() on the Simulator

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

back()[source]

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

focus(name)[source]

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

Parameters:name

(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.

Parameters:
  • parent – Parent tkinter.Widget
  • simSimulator instance to control
  • visualiserSimulatorVisualiser instance to take information from
  • kwargs – keyword arguments to pass to superclass constructor
_call(func)[source]

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

Parameters:
  • namestr used in property names
  • textstr to use as label
  • rowtkinter.Widget to attach to
_newRow(**kwargs)[source]

Create a new row to be used

Returns:The new Frame
tick()[source]

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.

accept(*args)[source]

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.

finish()[source]

Stop the visualiser and return to the main menu

focus()[source]

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

If in AUDRI mode, train the model

keyPress(event)[source]

Pass key press events to visualiser

mode
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
Type:int
restart()[source]

Reset random seed and restart visualiser using reset()

setDataset(name)[source]

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
tick()[source]

Call visualiser and panel tick frequently