+ 4
How to down the canvas without naming it
I want to make all of the rectangles get down, but its impossble to name them, someone can help me? https://code.sololearn.com/ckrn4Q5wGFNu/?ref=app
15 odpowiedzi
+ 4
+ 4
PyDan i know this, i want like, after 5 secs all the canvas that was made change their position
+ 3
PyDan Yeah, but what about changing their position instead of deleting them, is it possible?
+ 3
PyDan
https://code.sololearn.com/cQh6Z60cHyAz/?ref=app
Take a look at line 56, why it doesn't work?
+ 3
PyDan Their position didn't change
+ 2
Can you specify what is the real problem? What you want obtain? Its hard understand your problem without futher info
+ 1
It maybe like this
https://code.sololearn.com/cFGlcn6eWn5L/?ref=app
+ 1
I Am Not Arthur
Yes, it is
Example,
Assuming "canvas" move right, we have
x_pos +1
if x_pos >= parent.width:
x_pos *= -1
=> This is help "canvas" moving reverse (move left).
+ 1
Its still work
+ 1
another Animation
https://code.sololearn.com/c6275BZqnY6T/?ref=app
+ 1
But do you want move multiple rects (not widget) without store all refs? If yes, you can store the rects in an array and modify when you have to update they, the pos attribute.
See here for an example
https://code.sololearn.com/cNCdOt9Z6A07/?ref=app
0
Test it with pydroid 3
https://code.sololearn.com/cQsSl2M6IDP0/?ref=app
0
To Change properties of canvas
with widget.canvas:
Rectangle(
size=...,
pos=(x, y_pos)
# SEE HERE: y_pos
)
When you call Clock, y_pos will change its value
Move up: y_pos += 5
Move down: y_pos -= 5
0
It cannot work.
class Janela(FloatLayout):
Y=0
def __init__(self, **kwargs):
super().__init__(**kwargs)
with self.canvas:
Rectangle(size=(50,50), pos=(100, self.Y))
Clock.schedule_interval(self.update, 1/60)
def update(self, *args):
self.Y += 0.01