soar.gui.soar_ui

Soar Main GUI classes.

Classes for building the main GUI, which allows the user to load brains & worlds, start simulations, etc.

class soar.gui.soar_ui.ButtonFrame(master, image=None, text=None, command=None, state=None)

Bases: tkinter.Frame

A Tk frame containing an image Button and a Label immediately beneath it, arranged via the grid geometry manager.

button

The button inside the frame.

label

The label inside the frame.

Parameters:
  • master – The parent widget or window in which to place the frame.
  • image (optional) – The image to place inside the button.
  • text (optional) – The text to place inside the label.
  • command (optional) – The function to call when the button is clicked.
  • state (optional) – The state of the button, either NORMAL or DISABLED.
config(image=None, text=None, command=None, state=None)

Sets the parameters of the button/label.

Parameters:
  • image (optional) – The image to place inside the button.
  • text (optional) – The text to place inside the label.
  • command (optional) – The function to call when the button is clicked.
  • state (optional) – The state of the button, either NORMAL or DISABLED.
class soar.gui.soar_ui.IntegerEntry(parent, value='', **kwargs)

Bases: tkinter.Entry

A Tk entry that only allows integers.

Parameters:
  • parent – The parent Tk widget or window.
  • value (str) – The initial value. Must be able to be cast to int.
  • **kwargs – Arbitrary Tk keyword arguments.
class soar.gui.soar_ui.LoadingIcon(parent, file, frames)

Bases: tkinter.Label

An animated loading icon that can be shown or hidden.

Parameters:
  • parent – The parent Tk widget or window.
  • file (str) – The path to an animated .gif. The last frame should be empty/transparent.
  • frames (int) – The number of frames in the .gif.
class soar.gui.soar_ui.SoarUI(client_future, client_mainloop, parent=None, title='Soar 1.5.2')

Bases: tkinter.Tk

The main GUI window.

Parameters:
  • client_future – The function to call to schedule a future with the client.
  • client_mainloop – The client’s mainloop function, restarted after the main thread switches to Tk execution.
  • parent (optional) – The parent window. It is almost always unnecessary to change this from the default.
  • title (str, optional) – The main window title.
attach_window(w, linked=True)

Attach an existing window to the SoarUI.

Parameters:linked (bool) – If True, the window will be destroyed whenever the simulator window is destroyed.
Returns:The window that was attached.
brain_cmd()

Called when the brain button is pushed.

brain_ready()

Configure buttons and paths when a brain is loaded.

cancel_all_loading()

Hide the loading icon and delete all button state frames.

close_windows(close_unlinked=False)

Close windows, optionally unlinked ones, clear the draw queue, and set the simulator canvas to None.

Parameters:close_unlinked (bool) – If True, closes all windows. Otherwise, closes only the linked ones.
connect_cmd()

Called when the connect to robot button is pushed.

connect_load()

Called when the real robot’s requested reload has finished.

connect_ready()

Called when the real robot is ready.

controller_failure()

Called by the client when the controller fails.

controller_io_error()

Called when an error occurs connecting to the real robot.

done_loading()

Re-enable user interaction, and hide the loading icon.

future(func, *args, after_idle=False, **kwargs)

Executes a function (asynchronously) in the GUI event loop ASAP in the future.

gui_error()

Called when a GUI error occurs, such as an error while drawing a world or window.

initialize()

Initialize the grid geometry.

loading()

Disable user interaction and animate the loading icon.

mainloop(n=0)

Enter the Tk event loop, and restart the client as a new thread.

Redirect stdout and stderr to the GUI’s output frame.

on_close()

Called when the main window is closed.

pause_cmd()

Called when the pause button is pushed.

pause_ready()

Called when the controller has finished pausing.

play_cmd()

Called when the play button is pushed.

play_ready()

Called after the controller has started playing.

reload_cmd(reload_controller=True, clear_output=True, silent=False, close_unlinked=False, callback=None)

Kill the controller, close windows, and reload the brain and world.

Parameters:
  • reload_controller (bool) – If True, immediately reload whatever controller was in effect previously.
  • close_unlinked (bool) – If True, close all windows, not just the linked ones.
  • clear_output (bool) – If True, clears the output of the output frame.
  • silent (bool) – If True, stops the client from printing 'LOAD BRAIN'-like messages.
  • callback – The function to call after the reload has finished, or None.
reload_finished(reload_controller, sim_canvas, connected, callback)

Called after the client has finished reloading.

Parameters:
  • reload_controller (bool) – If True, reload the previous controller.
  • sim_canvas – If not None, the controller to be reloaded is the simulator.
  • connected – If True, the controller to be reloaded is the real robot controller.
  • callback – A function to call once the reload has finished, or None.
report_callback_exception(exc, val, traceback)

Report callback exception to sys.stderr, as well as notifying the Soar client.

In addition, signal any events that may need to be flagged for synchronous_future.

reset(clear_output=True)

Reset all of the button states to what they are at initialization, before any files are loaded.

Parameters:clear_output (bool, optional) – If True, clear the contents of the output frame.
sim_cmd()

Called when the simulator button is pushed.

sim_load()

Called when the simulator’s reload has finished.

sim_ready()

Called when the simulator is ready.

step_cmd()

Called when the step button is pushed.

step_finished()

Called when the controller finishes multi-stepping.

stop_cmd()

Called when the stop button is pushed.

stop_ready()

Called when the controller has stopped.

synchronous_future(func, *args, after_idle=False, **kwargs)

Executes a function in the GUI event loop, waiting either for its return, or for a Tk exception.

toplevel(linked=True)

Add a new window to the UI’s internal list, and return a new Toplevel window, optionally linked.

Parameters:linked (bool) – If True, the window will be destroyed whenever the simulator window is destroyed.
Returns:The new Toplevel window.
world_cmd()

Called when the world button is pushed.

world_ready(auto_sim_load=False)

Configure buttons and paths when a world is ready.