You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when I try to acess the width and height using this code
fromp5import*fromcomponents.shufflerimportShufflerfromcomponents.debuggerimportDebuggerfromgame_logic.constantsimportITEMS# Intellisense can't find these on its own for some reasonglobalmouse_is_pressed, mouse_x, mouse_yglobalshuffler, debuggerglobalwidth, heightSHUFFLED_ITEMS=list(ITEMS.keys())
img=Nonedefstart():
""" Start the UI. This function takes over the main thread (never returns)! """run(renderer="skia", sketch_draw=draw, sketch_setup=setup)
defsetup():
size(1024, 600) #touchscreen sizebackground(200)
globalshuffler, debugger, imgshuffler=Shuffler()
debugger=Debugger()
img=loadImage("kart_ui/images/no-item.png")
defdraw():
background(255)
print(type(img))
img_width=img.width()
img_height=img.height()
img_width=int(img_width/2)
img_height=int(img_height/2)
image(img, 10,20, img_width, img_height)
defmouse_pressed():
ifmouse_x<width/2:
shuffler.shuffle(SHUFFLED_ITEMS[int(random_uniform(0, len(SHUFFLED_ITEMS)))])
else:
shuffler.use_item()
if__name__=="__main__":
start()
i get this error
Traceback (most recent call last):
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/kart_ui/__init__.py", line 47, in <module>
run()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/p5/sketch/userspace.py", line 226, in run
app.run()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/_default_app.py", line 60, in run
return default_app.run()
^^^^^^^^^^^^^^^^^
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/application.py", line 160, in run
return self._backend._vispy_run()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/backends/_glfw.py", line 189, in _vispy_run
self._vispy_process_events()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/backends/_glfw.py", line 178, in _vispy_process_events
timer._tick()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/backends/_glfw.py", line 512, in _tick
self._vispy_timer._timeout()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/app/timer.py", line 160, in _timeout
self.events.timeout(
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/util/event.py", line 453, in __call__
self._invoke_callback(cb, event)
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/util/event.py", line 471, in _invoke_callback
_handle_exception(self.ignore_callback_errors,
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/vispy/util/event.py", line 469, in _invoke_callback
cb(event)
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/.venv/lib/python3.11/site-packages/p5/sketch/Vispy2DRenderer/base.py", line 114, in on_timer
self.draw_method()
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/kart_ui/__init__.py", line 34, in draw
img_width = img.width()
^^^^^^^^^^^
**TypeError: 'int' object is not callable**
however when I switch the lines accessing width and height to the following
img_width=img.widthimg_height=img.height
then I get the error
File "/Users/tytodd/Desktop/Projects/kai_kartsV2/v2/kart_ui/__init__.py", line 36, in draw
img_width = int(img_width()/2)
^^^^^^^^^^^
TypeError: 'int' object is not callable
So I'm confused am I supposed to access width and height as functions or attributes?
The text was updated successfully, but these errors were encountered:
This is the original image rendered with
when I try to acess the width and height using this code
i get this error
however when I switch the lines accessing width and height to the following
then I get the error
So I'm confused am I supposed to access width and height as functions or attributes?
The text was updated successfully, but these errors were encountered: