Python code to add set of images and display images randomly using after function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python code to add set of images and display images randomly using after function

14th Dec 2019, 10:07 AM
being pratik
being pratik - avatar
9 Answers
0
Very little info
14th Dec 2019, 10:10 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
No...I know how to display image.....the question is to add set of images and display each image at a particular time interval by setting timer using after() function
14th Dec 2019, 10:22 AM
being pratik
being pratik - avatar
0
being pratik I think I answered. You gave us very little info, what framework are you using to manipulate images ? What GUI are you using ? How are the pictures stored ? Come on, how do you expect us to answer.
14th Dec 2019, 10:25 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
I am working with Pillow and Tkinter module
14th Dec 2019, 10:26 AM
being pratik
being pratik - avatar
0
Can you share your code here ?
14th Dec 2019, 10:27 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
being pratik if you managed to make a working app with tkinter and PIL, then you have done the hard part. All you need to do is add the random function, that will randomly choose images from the set. For the interval, use the time module.
14th Dec 2019, 10:29 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Sorry....I am unable to code this question...I do not know how to add timer in image
14th Dec 2019, 10:29 AM
being pratik
being pratik - avatar
0
being pratik you don't add the time in the image. Create a new function in tkinter, for example: def random_pic(): pic = random.choices(list_of_pictures) And then set an interval to repeat this function over and over again.
14th Dec 2019, 10:32 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
import sleep, then sleep(time in secends) and that will pause the code where it is and start back after the time set has finished
20th Apr 2020, 12:16 PM
G4M3S4L1F3
G4M3S4L1F3 - avatar