如何显示图像,关闭并显示下一个图像
我想为美国手语手柄制定培训计划。我为字母组的每个字母都有一个图像库,想一次通过一个字符读取脚本,然后显示一组毫秒数的手指下图像,然后转到下一个图像。 我是编程的新手,很喜欢以菜鸟为导向的答案,谢谢! 该脚本根据“ Awesome.txt”中的文本打开了正确的图像,但是我有一些我不知道如何解决的问题:
- 这些图像在Windows照片中打开,另一个在另一个上堆放。我需要它们在屏幕上闪烁以获取毫秒#的集合,并由下一个图像替换。
- 如果角色不是字母,我需要一个捕捉,因此它会跳过并继续前进。 这是我到目前为止写的代码:
from PIL import Image
delaytime=input("set speed in milliseconds")
def displayme(imagename):
image = Image.open(imagename)
image.show()
time.sleep(int(delaytime)/1000)
image.close()
file = open('awesome.txt', 'r')
while 1:
# read by character
char = file.read(1)
imagename=char+".png"
if not char:
break
displayme(imagename)
file.close()
I want to create a training program for American Sign Language fingerspelling. I have a library of images for each letter of the alphabet and would like to have the script read through a text file one character at a time and then display the fingerspelling image for a set number of milliseconds, then move on to the next image.
I am new to programming and would appreciate noob-oriented answers, thanks!
The script opens the correct images based on the text in “awesome.txt”, but I have a couple issues I don’t know how to resolve:
- The images are opening in Windows Photos and piling one on top of the other. I need them to flash on the screen for the set # of milliseconds and be replaced by the next image.
- I need a catch in case the character is not a letter, so it skips it and moves on to the next.
This is the code I have written so far:
from PIL import Image
delaytime=input("set speed in milliseconds")
def displayme(imagename):
image = Image.open(imagename)
image.show()
time.sleep(int(delaytime)/1000)
image.close()
file = open('awesome.txt', 'r')
while 1:
# read by character
char = file.read(1)
imagename=char+".png"
if not char:
break
displayme(imagename)
file.close()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我想到的:
尝试 this 用于间隔调用回调函数
That's what I came up with:
Try this for calling callback function in interval