title: Working with indefinite number of canvas objects
body: <p>I am trying to make some kind of drawing tool that draws predefined shapes such as line, box etc on tkinter.</p>
  
  <p><strong>PROBLEM1:</strong> I want to add redo-undo buttons such that when I undo, the last object will be removed and redo, the last object will be added. I thought I can tag each object when created and store every object's tags in a list, but I couldn't get a reasonable solution. </p>
  
  <p><strong>PROBLEM2:</strong> How will I be able to add the last deleted object? If I delete by tag -undoing event-, the data is lost as far as I know. I shouldn't be losing data I guess.</p>
  
  <p>A sample of pseudo-code below:</p>
  
  <pre><code>line=create_line(...)
  ...
  #tag should be assigned for further access
  ...
  stack.append(tag)
  ...
  #deleting by tag in undo event
  undo(event): stack.pop()
  
  #adding by tag in redo event
  redo(event):
      stack.append(lasttag)
      #problem2: adding the last object
  </code></pre>
  
  <p>I didn't want to draw all borders, but for the sake of clarity, I added these lines. Suggested solutions may be in a larger, more flexible context as long as they answer the question. Thanks in advance</p>