title: Can I create random x and y coordinates for a button - Tkinter Python
body: <pre><code>import tkinter as tk 
  import random
  
  root = tk.Tk() 
  
  canvas = tk.Canvas(root, height=600, width=700, bg=&quot;#4f75b3&quot;)
  canvas.pack()
  
  frame = tk.Frame(root, bg=&quot;#66bd5e&quot;)
  frame.place(relx=0.075, rely=0.075, relheight=0.85, relwidth=0.85,)
  
  def destroymole():
      mole.destroy()
  
  mole = tk.Button(root,text=&quot;MOLE&quot;, relief=&quot;raised&quot;, command=destroymole, x=random.randint(300,700), y=random.randint(300, 700), height=20, width=30)
  
  root.mainloop()
  </code></pre>
  <p>After running this I get this error</p>
  <pre><code>Traceback (most recent call last):   File
  &quot;C:\Users\\PycharmProjects\pythonProject\GUI APP.py&quot;, line 15, in
  &lt;module&gt;
      mole = tk.Button(root, text=&quot;MOLE&quot;,relief=&quot;raised&quot;, command=destroymole, x=random.randint(300,700),y=random.randint(300,
  700), height=20, width=30)   File
  &quot;C:\Users\\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py&quot;,
  line 2647, in __init__
      Widget.__init__(self, master, 'button', cnf, kw)   File &quot;C:\Users\\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py&quot;,
  line 2569, in __init__
      self.tk.call(
  _tkinter.TclError: unknown option &quot;-x&quot;
  </code></pre>
  <p>However, the main one is the last line and I'm pretty sure it is to do with the random number</p>
  <p>If there are any other apparent issues then please tell me because this is all a mystery to me.</p>