Making an extremely simple program where a button follows the mouse, and when clicked, should randomly resize. But I when I run the code below, I get an error, saying that the “height” property is unknown.
Code:
<code>import tkinter as tk
from tkinter import ttk
import random
window = tk.Tk()
def moved(e):
myx = e.x
myy = e.y
mylbl.place(x=myx - 20, y=myy - 20)
def randomsize():
size = random.randrange(20, 200)
sizey = size * 2
mylbl.config(width= sizey, height = size)
mylbl = ttk.Button(window, text="Hello", command=randomsize, height=30, width = 60)
mylbl.place(x=10, y=10)
window.bind("<Motion>", moved)
window.mainloop()
</code>
<code>import tkinter as tk
from tkinter import ttk
import random
window = tk.Tk()
def moved(e):
myx = e.x
myy = e.y
mylbl.place(x=myx - 20, y=myy - 20)
def randomsize():
size = random.randrange(20, 200)
sizey = size * 2
mylbl.config(width= sizey, height = size)
mylbl = ttk.Button(window, text="Hello", command=randomsize, height=30, width = 60)
mylbl.place(x=10, y=10)
window.bind("<Motion>", moved)
window.mainloop()
</code>
import tkinter as tk
from tkinter import ttk
import random
window = tk.Tk()
def moved(e):
myx = e.x
myy = e.y
mylbl.place(x=myx - 20, y=myy - 20)
def randomsize():
size = random.randrange(20, 200)
sizey = size * 2
mylbl.config(width= sizey, height = size)
mylbl = ttk.Button(window, text="Hello", command=randomsize, height=30, width = 60)
mylbl.place(x=10, y=10)
window.bind("<Motion>", moved)
window.mainloop()
Error:
<code>in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-height"
</code>
<code>in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-height"
</code>
in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-height"