Hey bro, Great anim. Please add double buffer to prevent screen tearing and also synchronizes refresh with vertical blank line / end of screen refresh. That will make the result smoother. You can also alter the spaceship sprite by inverting it horizontally and vertically according to the bump so the anim is more interesting. And scroll the background to get the whole show more realistic. When you combine both realism with fantasy that creates a contrast which makes things far more fun and interesting. Thanks for the tutorial.
This- now THIS is what I was looking for. *chef's kiss* many thanks; I wanted to emulate sprites with tkinter, and I assume I should be able to create buttons with images from here...
Thank you for this tutorial, I am a new user of python, and I use different elements that I just learned and combine them together. Your tutorial helped me to create a little code that make a face animation.
I wish this tutorial was more complete because I spent like 2 hours trying to figure out how to insert the image as a file in pycharm, and then it still didn't work, until I figured out that it doesn't work with jpg for some reason, until I decided to use PNG, why? I don't know, I just started Python yesterday
Try inserting jpg but also png files with: space_image = ImageTk.PhotoImage(Image.open("space.jpg")) and then open it normally in canvas with: my_space_image = canvas.create_image(0,0,image=space_image, anchor = NW)
hey Bro. when i swap the position of 2 lines: canvas.move and if conditions, the image can't bounce back when it reaches the right border and keep sticking that way and moving down 'till it reaches the bottom border. Can you explain that for me
If you listened closely, he said why. The conditions need to be before otherwise the image won't bounce back. Stop conditions are always at the beggining of a while loop so when we reenter the loop, we can verify the conditions.
That error won't show up in the practice since the force stop we have access from console only, you can simply add a key bind with the .quit method function. to be able to close the app without pressing stop in console. hope that helps.
@@Amir_Plays_non_stop my pleasure to help, I am learning a lot whith these videos, very useful channel I am finding similar channels here and there but this one has helped me the most so far.
I found other solution on web: This error is caused by close button on top-right corner of window, the only way you have to stop script. After you click close button, window is destroyed, so no widget, like canvas, exist. You can set a flag to identify if while loop should stop and exit in handler of window close button event. Translating from aliens to human language: add def handler(): global run run = False window.protocol("WM_DELETE_WINDOW", handler) run = True while run : (yours while loop content here) window.destroy() window.mainloop() change in code True for: while run : and before closing a window.mainloop() insert closing a window with: window.destroy()
when i place my image on the 0,0 coordinates i find it in the center of the canvas i dont how to solve that...this one did not work for me. i literally copied and pasted his code n same problm occured
I have a question, xvelocity and yvelocity appear to be in this code just simple variables so I don't get why they worked at all unless they are specific keywords inside python and therefore understood. That is confusing me since they don't seem to be linked to a function or defined piece of logic to perform that action or at least it seems so. for example if I call them something else like my_variable how in the world they are understood. Please send help I'm stuck there. Edit: I understood now cause canvas .move is expecting int coordinates as parameters. Wow. hope that helps someone else too.
There are ready ones on the internet but you can create your own in a photo editor to remove backgrounds manually. Or if you meant a transparency efect you can do that as well in Photoshop for example.
Tried to realise your demo, but...it seems tkinter can't show .png with RGB-A with alpha channel.. how do you achieve that, the little ufo.png without background color?!
from tkinter import *
import time
WIDTH = 500
HEIGHT = 500
xVelocity = 1
yVelocity = 1
window = Tk()
canvas = Canvas(window,width=WIDTH,height=HEIGHT)
canvas.pack()
background_photo = PhotoImage(file='space.png')
background = canvas.create_image(0,0,image=background_photo,anchor=NW)
photo_image = PhotoImage(file='ufo.png')
my_image = canvas.create_image(0,0,image=photo_image,anchor=NW)
image_width = photo_image.width()
image_height = photo_image.height()
while True:
coordinates = canvas.coords(my_image)
print(coordinates)
if(coordinates[0]>=(WIDTH-image_width) or coordinates[0]=(HEIGHT-image_height) or coordinates[1]
@datrix North West it is used to place the object at the north west of the window
What's the version of the Python that you used here? Mine is Python 2.7 and I cannot display the png images, only gif images
0
you are the best. You are putting the best efforts possible in your videos. And Also The best phyton are yours.👑👑👑
Hey bro,
Great anim. Please add double buffer to prevent screen tearing and also synchronizes refresh with vertical blank line / end of screen refresh. That will make the result smoother.
You can also alter the spaceship sprite by inverting it horizontally and vertically according to the bump so the anim is more interesting. And scroll the background to get the whole show more realistic.
When you combine both realism with fantasy that creates a contrast which makes things far more fun and interesting.
Thanks for the tutorial.
You're my best online tutor
This- now THIS is what I was looking for. *chef's kiss*
many thanks; I wanted to emulate sprites with tkinter, and I assume I should be able to create buttons with images from here...
Hey Bro!!. So much time!!! Great Video!!!!
thank you Lucy
Thank you for this tutorial, I am a new user of python, and I use different elements that I just learned and combine them together. Your tutorial helped me to create a little code that make a face animation.
This was so Kool learning how to Animate 2D with one image and a different image for the Background‼️🏆
Great tutorial. Keep it coming.
Bonjour vidéo très bien tournée merci !
Great tutorial thanks a lot!
Is it possible to store the created animation, e.g. in gif or mp4 format?
yes, simply use screen recorder such as Fast Stone Capture eeeeeeeeeee thaaat is ma opinion
Ty bro!
very interesting, I want to learn animation of graph plotting
Then I would suggest you to watch matplotlib tutorials
Thanks.
thanks for helping us.. BRO...!!!
Hi , can we create an animation for elevator door open and close using python. is it possible?
Another way to reverse the motion is to write xV *= -1
step 3 = done
step 1 = done 👍
step 2 = done 🗯
thats how screensavers were born. Thanks Bro!!!
Hello Bro. Can I ask if animations also works on buttons?
Fantastic!!!
Life saver video!
so cool!
I wish this tutorial was more complete because I spent like 2 hours trying to figure out how to insert the image as a file in pycharm, and then it still didn't work, until I figured out that it doesn't work with jpg for some reason, until I decided to use PNG, why? I don't know, I just started Python yesterday
Try inserting jpg but also png files with: space_image = ImageTk.PhotoImage(Image.open("space.jpg")) and then open it normally in canvas with: my_space_image = canvas.create_image(0,0,image=space_image, anchor = NW)
Great.....
hey Bro. when i swap the position of 2 lines: canvas.move and if conditions, the image can't bounce back when it reaches the right border and keep sticking that way and moving down 'till it reaches the bottom border. Can you explain that for me
If you listened closely, he said why. The conditions need to be before otherwise the image won't bounce back. Stop conditions are always at the beggining of a while loop so when we reenter the loop, we can verify the conditions.
Thank you so much for this tutorial, can anyone help how to send this to a friend so they can see my progression with coding?
Bro code, thanks so much for your help.
Thank you Bro!
I am curious to know how you learned all that you learned about Python
How did you put the image in a file?
its actually dark for me too, it would be perfect if he showed everything step by step
So this is the code DSTV used for their old decoders
my background image is not showing how can i solve this problem?
How can we fix the error when we close the stop the application? I tried to catch it using try and catch but didn't work.
That error won't show up in the practice since the force stop we have access from console only, you can simply add a key bind with the .quit method function. to be able to close the app without pressing stop in console. hope that helps.
@@davidcalebpaterson7101 thanks alot bro!
@@Amir_Plays_non_stop my pleasure to help, I am learning a lot whith these videos, very useful channel I am finding similar channels here and there but this one has helped me the most so far.
I found other solution on web: This error is caused by close button on top-right corner of window, the only way you have to stop script. After you click close button, window is destroyed, so no widget, like canvas, exist. You can set a flag to identify if while loop should stop and exit in handler of window close button event. Translating from aliens to human language: add def handler():
global run
run = False
window.protocol("WM_DELETE_WINDOW", handler)
run = True
while run :
(yours while loop content here)
window.destroy()
window.mainloop()
change in code True for: while run : and before closing a window.mainloop() insert closing a window with: window.destroy()
bro but what about images
Wow!!!
when i place my image on the 0,0 coordinates i find it in the center of the canvas i dont how to solve that...this one did not work for me. i literally copied and pasted his code n same problm occured
8:51 have a problem bro, in coordinates[0],
"cannot find reference"[" in 'None'
I have a question, xvelocity and yvelocity appear to be in this code just simple variables so I don't get why they worked at all unless they are specific keywords inside python and therefore understood. That is confusing me since they don't seem to be linked to a function or defined piece of logic to perform that action or at least it seems so. for example if I call them something else like my_variable how in the world they are understood. Please send help I'm stuck there.
Edit: I understood now cause canvas .move is expecting int coordinates as parameters. Wow. hope that helps someone else too.
Then they are not a keywords yeah??
Am I right that the mainloop function never gets used in this program?
it does
how do you get the image transparent??
There are ready ones on the internet but you can create your own in a photo editor to remove backgrounds manually. Or if you meant a transparency efect you can do that as well in Photoshop for example.
remove.bg
oh hell yeah
What if I smallize the letter v in xvelocity
Is move() a keywors or its a variable
Because its not defined
its a class method, canvas is a class that derived from the tkinter properties.
i perform all the three steps :)
how can i get your images bro
Don’t give up
I'm still determined, don't worry
Bro Code imma sub
it just like dvd
hey Bro... does PhotoImage support jpg format?
are u also having that issue too?
okay, i did this program, and I already feel how Google and Apple are wants me to work with them😎😂😂😂
Tried to realise your demo, but...it seems tkinter can't show .png with RGB-A with alpha channel.. how do you achieve that, the little ufo.png without background color?!