Web Analytics Made Easy - Statcounter
Skip to content

Graph

Creates an area for you to draw on. The MAGICAL property this Element has is that you interact with the element using your own coordinate system. This is an important point!! YOU define where the location is for (0,0). Want (0,0) to be in the middle of the graph like a math 4-quadrant graph? No problem! Set your lower left corner to be (-100,-100) and your upper right to be (100,100) and you've got yourself a graph with (0,0) at the center. One of THE coolest of the Elements. Drawing primitives return an "id" that is referenced when you want to operation on that item (e.g. to erase it)

Graph(
    canvas_size,
    graph_bottom_left,
    graph_top_right,
    background_color = None,
    pad = None,
    change_submits = False,
    drag_submits = False,
    size_px = (None, None),
    enable_events = False,
    key = None,
    visible = True,
    disabled = False,
    tooltip = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
canvas_size (int, int) size of the canvas area in pixels
change_submits bool False * DEPRICATED DO NOT USE. Use enable_events instead
disabled bool False disable or enable state of the element
drag_submits bool False if True and Events are enabled for the Graph, will report Events any time the mouse moves while button down. When the mouse button is released, you'll get an event = graph key + '+UP' (if key is a string.. if not a string, it'll be made into a tuple)
enable_events bool False Turns on the element specific events. Combo event is when a choice is made
graph_bottom_left (int, int) (x,y) The bottoms left corner of your coordinate system
graph_top_right (int, int) (x,y) The top right corner of your coordinate system
key str or int or tuple or object None Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
tooltip str None text, that will appear when mouse hovers over the element
visible bool True set visibility state of the element (Default = True)

Class Properties

This class has no public properties

Class Methods

 def change_coordinates
 def click_callback
 def delete_figure
 def draw_circle
 def draw_image
 def draw_line
 def draw_oval
 def draw_point
 def draw_rectangle
 def draw_text
 def erase
 def move
 def move_figure
 def relocate
 def relocate_figure
 def update

change_coordinates

Changes the coordinate system to a new one. The same 2 points in space are used to define the coorinate system - the bottom left and the top right values of your graph.

change_coordinates(
    graph_bottom_left,
    graph_top_right
)

Parameter Descriptions

Name Type Default Description
graph_bottom_left (int, int) (x,y) The bottoms left corner of your coordinate system
graph_top_right (int, int) (x,y) The top right corner of your coordinate system

click_callback

click_callback(
    widget,
    args = *<1 or N objects>
)

delete_figure

Remove a figure from the Graph.

delete_figure(
    figure
)

Parameter Descriptions

Name Type Default Description
figure (remi.gui.SvgCircle) the figure

draw_circle

Draws a circle, cenetered at the location provided. Can set the fill and outline colors

draw_circle(
    center_location,
    radius,
    fill_color = None,
    line_color = "black"
)

Parameter Descriptions

Name Type Default Description
center_location (int, int) or Tuple[float, float] Center location using USER'S coordinate system
fill_color str None color of the point to draw
line_color str black color of the outer line that goes around the circle (sorry, can't set thickness)
radius int or float Radius in user's coordinate values.
RETURN int or None id returned from tkinter that you'll need if you want to manipulate the circle

draw_image

Places an image onto your canvas. It's a really important method for this element as it enables so much

draw_image(
    data = None,
    image_source = None,
    location = (None, None),
    size = (100, 100)
)

Parameter Descriptions

Name Type Default Description
data str or bytes None if image is in Base64 format or raw? format then use instead of filename
image_source str None if image is in a file, path and filename for the image. (GIF and PNG only!)
location (int, int) or Tuple[float, float] (None, None) the (x,y) location to place image's top left corner
RETURN int or None id returned from tkinter that you'll need if you want to manipulate the image

draw_line

Draws a line from one point to another point using USER'S coordinates. Can set the color and width of line

draw_line(
    point_from,
    point_to,
    color = "black",
    width = 1
)

Parameter Descriptions

Name Type Default Description
color str black Color of the line
point_from (int, int) or Tuple[float, float] Starting point for line
point_to (int, int) or Tuple[float, float] Ending point for line
width int 1 width of line in pixels
RETURN int or None id returned from tktiner or None if user closed the window. id is used when you

draw_oval

Draws an oval based on coordinates in user coordinate system. Provide the location of a "bounding rectangle"

draw_oval(
    top_left,
    bottom_right,
    fill_color = None,
    line_color = None
)

Parameter Descriptions

Name Type Default Description
bottom_right (int, int) or Tuple[float, float] the bottom right point of bounding rectangle
fill_color str None color of the interrior
line_color str None color of outline of oval
top_left (int, int) or Tuple[float, float] the top left point of bounding rectangle
RETURN int or None id returned from tkinter that you'll need if you want to manipulate the oval

draw_point

Draws a "dot" at the point you specify using the USER'S coordinate system

draw_point(
    point,
    size = 2,
    color = "black"
)

Parameter Descriptions

Name Type Default Description
color str black color of the point to draw
point (int, int) or Tuple[float, float] Center location using USER'S coordinate system
size int or float 2 Radius? (Or is it the diameter?) in user's coordinate values.
RETURN int or None id returned from tkinter that you'll need if you want to manipulate the point

draw_rectangle

Draw a rectangle given 2 points. Can control the line and fill colors

draw_rectangle(
    top_left,
    bottom_right,
    fill_color = None,
    line_color = "black"
)

Parameter Descriptions

Name Type Default Description
bottom_right (int, int) or Tuple[float, float] the bottom right point of rectangle
fill_color str None color of the interior
line_color str black color of outline
top_left (int, int) or Tuple[float, float] the top left point of rectangle
RETURN int or None int

draw_text

Draw some text on your graph. This is how you label graph number lines for example

draw_text(
    text,
    location,
    color = "black",
    font = None,
    angle = 0
)

Parameter Descriptions

Name Type Default Description
angle float 0 Angle 0 to 360 to draw the text. Zero represents horizontal text
color str black text color
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
location (int, int) or Tuple[float, float] location to place first letter
text Any text to display
RETURN int or None id returned from tkinter that you'll need if you want to manipulate the text

erase

Erase the Graph - Removes all figures previously "drawn" using the Graph methods (e.g. DrawText)

erase()

move

Moves the entire drawing area (the canvas) by some delta from the current position. Units are indicated in your coordinate system indicated number of ticks in your coordinate system

move(
    x_direction,
    y_direction
)

Parameter Descriptions

Name Type Default Description
x_direction int or float how far to move in the "X" direction in your coordinates
y_direction int or float how far to move in the "Y" direction in your coordinates

move_figure

Moves a previously drawn figure using a "delta" from current position

move_figure(
    figure,
    x_direction,
    y_direction
)

Parameter Descriptions

Name Type Default Description
figure id Previously obtained figure-id. These are returned from all Draw methods
x_direction int or float delta to apply to position in the X direction
y_direction int or float delta to apply to position in the Y direction

relocate

relocate(
    x,
    y
)

Parameter Descriptions

Name Type Default Description
x
y

relocate_figure

Move a previously made figure to an arbitrary (x,y) location. This differs from the Move methods because it uses absolute coordinates versus relative for Move

relocate_figure(
    figure,
    x,
    y
)

Parameter Descriptions

Name Type Default Description
figure id Previously obtained figure-id. These are returned from all Draw methods
x int or float location on X axis (in user coords) to move the upper left corner of the figure
y int or float location on Y axis (in user coords) to move the upper left corner of the figure

update

Changes some of the settings for the Graph Element. Must call Window.Read or Window.Finalize prior

Changes will not be visible in your window until you call window.read or window.refresh.

update(
    background_color
)

Parameter Descriptions

Name Type Default Description
background_color str color of background. Can be in #RRGGBB format or a color name "black"