title: How to draw a polygon on a tkinter canvas using a class?
body: <pre><code>from tkinter import*
  
  root = Tk()
  shape = Canvas(root)
  
  class GUI():
      def __init__(self):
          pass
  
      def create_polygon(self, points, colour, posit):
          try:
              shape.delete(self.poly)
          except:
              pass
          self.poly = shape.create_polygon(points, colour, posit)
          self.poly.shape.grid(column=posit[0],row=posit[1])
  
  polygon = GUI()
  polygon.create_polygon([150,75,225,0,300,75,225,150],'yellow',[1,2])
  </code></pre>
  
  <p>I'm new to using <code>tkinter</code> and classes but I want to make a very simple class to create a regular polygon. The code in this program should delete any polygon previously made and then proceed to make a new polygon when the program is called but I keep getting an error that I don't understand. Also how would you go about drawing a hexagon instead?</p>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "//xsvr-02/Students/10SAMP_Al/HW/polygon creator.py", line 19, in &lt;module&gt;
  polygon.create_polygon([150,75,225,0,300,75,225,150],'yellow',[1,2])
   File "//xsvr-02/Students/10SAMP_Al/HW/polygon creator.py", line 15, in create_polygon
  self.poly = shape.create_polygon(points, colour, posit)
   File "C:\Python34\lib\tkinter\__init__.py", line 2305, in create_polygon
  return self._create('polygon', args, kw)
  File "C:\Python34\lib\tkinter\__init__.py", line 2287, in _create
  *(args + self._options(cnf, kw))))
  _tkinter.TclError: wrong # coordinates: expected an even number, got 11
  </code></pre>