title: I Can't Get Whiteboard To Draw After Setting IT At Toplevel - Tkinter
body: <p>When set as root the whiteboard functions correctly, now moved to a Toplevel popup, lines can only emanate from 0,0 outward, creating nice graphical lines from the top left corner. NOT THE INTENDED OBJECTIVE..mmm.</p>
  
  <p>I suspect it has something to do with my 'global' statements but I'm stuck never the less.  Here is the code as it sits Toplevel within a shell canvas:</p>
  
  <pre><code># WHITEBOARD POPUP
  def whiteboardPanel():
      whitePanel = Toplevel(root)
      whitePanel.transient(root)
      whitePanel.title("WHITEBOARD")
      whitePanel.minsize(550,600)
      whitePanel.maxsize(550,600)
      #whitePanel.focus_set()
      #whitePanel.grab_set()
      whitePanel.geometry("550x600+1800+215")
  
      lastX, lastY = 0, 0
  
      colour = "black"
  
      erase = "white"
      thick = 5
  
      # =========  FUNCTION DEF ==========
  
      def set_colour_red(event):
         global colour
          colour = "red"
         thick = 5
  
      def set_colour_green(event):
         global colour
         colour = "green"
         thick = 5
  
     def set_colour_black(event):
         global colour
         colour = "black"
         thick = 5
  
     def set_colour_erase(event):
         global colour
         colour = "white"
         thick = 10
  
     def store_position(event):
         lastX = event.x
         lastY = event.y
  
     def on_click(event):
         store_position(event)
  
     def on_drag(event):
         lastX, lastY = 0, 0
  
         canvas.create_line(lastX, lastY, event.x, event.y, fill=colour, width=thick)
         store_position(event)
  
  canvas = Canvas(whitePanel, width=550, height=600, bg="white")
  canvas.pack()
  # fill='both', expand=True, padx=6, pady=6)
  canvas.bind("&lt;Button-1&gt;", on_click)
  canvas.bind("&lt;B1-Motion&gt;", on_drag)
  red_id = canvas.create_rectangle(10, 10, 30, 30, fill="red")
  green_id = canvas.create_rectangle(10, 35, 30, 55, fill="green")
  black_id = canvas.create_rectangle(10, 60, 30, 80, fill="black")
  erase_id = canvas.create_rectangle(10, 85, 30, 105, fill="white")
  
  canvas.tag_bind(red_id, "&lt;Button-1&gt;", set_colour_red)
  canvas.tag_bind(green_id, "&lt;Button-1&gt;", set_colour_green)
  canvas.tag_bind(black_id, "&lt;Button-1&gt;", set_colour_black)
  canvas.tag_bind(erase_id, "&lt;Button-1&gt;", set_colour_erase)
  
  
  ....somewhere down below
  ....root.mainloop()
  </code></pre>
  
  <p>Note that other Toplevel windows work fine and there is no issue outside of the drawing issue.</p>