soar.gui.canvas

Soar canvas classes and methods.

Defines SoarCanvas and SoarCanvasFrame classes, as well as a method of creating them from an instance of soar.sim.world.World.

class soar.gui.canvas.SoarCanvas(parent, **options)

Bases: tkinter.Canvas

A metered, resizable Tkinter canvas. All drawing operations take metered arguments, where x values increase rightwards and y values increase upwards.

Parameters:
  • parent – The parent window or widget in which the canvas is placed.
  • **options – Tk options.
create_arc(*args, **kw)

Create arc shaped region with coordinates x1,y1,x2,y2.

create_bitmap(*args, **kw)

Create bitmap with coordinates x1,y1.

create_image(*args, **kw)

Create image item with coordinates x1,y1.

create_line(*args, **kw)

Create line with coordinates x1,y1,…,xn,yn.

create_oval(*args, **kw)

Create oval with coordinates x1,y1,x2,y2.

create_polygon(*args, **kw)

Create polygon with coordinates x1,y1,…,xn,yn.

create_rectangle(*args, **kw)

Create rectangle with coordinates x1,y1,x2,y2.

create_text(*args, **kw)

Create text with coordinates x1,y1.

on_resize(event)
remap_coords(coords)
class soar.gui.canvas.SoarCanvasFrame(parent, **options)

Bases: tkinter.Frame

A resizable frame that holds a SoarCanvas.

on_resize(event)
soar.gui.canvas.canvas_from_world(world, toplevel=<class 'tkinter.Toplevel'>, close_cmd=None)

Return a soar.gui.canvas.SoarCanvas in a new window from a World. Optionally, call a different toplevel() method to create the window, and set its behavior on close.

Additionally, if an object in the world defines on_press, on_release, and on_motion methods, bind those to the associated mouse events for that tag, making it draggable.

Parameters:
  • world – An instance of soar.sim.world.World or a subclass.
  • toplevel (optional) – The function or method to call to create the window itself.
  • close_cmd (optional) – The function or method to call when the window is destroyed.
Returns:

The new SoarCanvas.