Reputation: 11
I tried an example of the meter widget of ttkbootstrap and it doesn't seem to work. I copy and pasted the exact code and got this error 'AttributeError: module 'PIL.Image' has no attribute 'CUBIC'. Did you mean: 'BICUBIC'?'
This is the code
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
app = ttk.Window()
meter = ttk.Meter(
metersize=180,
padding=5,
amountused=25,
metertype="semi",
subtext="miles per hour",
interactive=True,
)
meter.pack()
# update the amount used directly
meter.configure(amountused = 50)
# update the amount used with another widget
entry = ttk.Entry(textvariable=meter.amountusedvar)
entry.pack(fill=X)
# increment the amount by 10 steps
meter.step(10)
# decrement the amount by 15 steps
meter.step(-15)
# update the subtext
meter.configure(subtext="loading...")
app.mainloop()
`
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\ttkbootstrap\gui-intro\meter\main.py", line 6, in <module>
meter = ttk.Meter(
^^^^^^^^^^
File "C:\Users\User\PycharmProjects\ttkbootstrap\venv\Lib\site-packages\ttkbootstrap\widgets.py", line 718, in __init__
self._setup_widget()
File "C:\Users\User\PycharmProjects\ttkbootstrap\venv\Lib\site-packages\ttkbootstrap\widgets.py", line 759, in _setup_widget
self._draw_meter()
File "C:\Users\User\PycharmProjects\ttkbootstrap\venv\Lib\site-packages\ttkbootstrap\widgets.py", line 856, in _draw_meter
img.resize((self._metersize, self._metersize), Image.CUBIC)
^^^^^^^^^^^
AttributeError: module 'PIL.Image' has no attribute 'CUBIC'. Did you mean: 'BICUBIC'?
Process finished with exit code 1
Upvotes: 1
Views: 2994
Reputation: 46678
As the attribute Image.CUBIC
is deprecated (replaced by Image.BICUBIC
) and removed in Pillow
v10.0.0. Either install an older version (v9.5.0) of Pillow
module or create the attribute explicitly before importing ttkbootstrap
module:
from PIL import Image
Image.CUBIC = Image.BICUBIC
import ttkbootstrap as ttk
...
Upvotes: 4