Skip to content

Work inside google colab #33

@urrameu

Description

@urrameu

Hi,

Would it be possible to make the package work correctly inside google colab? The problem I noticed (there may be others) is that .turtle_undraw() uses grid.remove(), which causes colab to create a new graphic area at every call. I tried to change .turtle_undraw():

.turtle_undraw <- function()
{
   grid.remove("turtle_head", redraw=FALSE)
   grid.remove("turtle_body", redraw=FALSE)
   grid.remove("turtle_leg1", redraw=FALSE)
   grid.remove("turtle_leg2", redraw=FALSE)
   grid.remove("turtle_leg3", redraw=FALSE)
   grid.remove("turtle_leg4", redraw=FALSE)
   invisible(NULL)
}

But this does not remove/undraw the turtle. Eliminating redraw=FALSE from just the last line does remove/undraw the turtle and reduces the number of bogus graphic areas, but that is not a solution.

As a workaround, I eliminated the turtle image completely:

library("TurtleGraphics")
fakedraw <- function() {invisible(NULL)}
environment(fakedraw) <- asNamespace('TurtleGraphics')
assignInNamespace(".turtle_draw",fakedraw, ns="TurtleGraphics")
assignInNamespace(".turtle_undraw",fakedraw, ns="TurtleGraphics")
turtle_init()

which is obviously not great but apparently works ok, at least for simple stuff.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions