当输入与product变量中的条形码匹配时,我想使用此代码将背景图像更改为相应的条形码。到目前为止,我在名称变量下使用了一些字符串来代替计算机上的五个jpeg图像。
我不知道如何处理,但是每次用户更改输入时,我都希望背景更改为该图像。关于如何实现的任何想法?
最终目标是使用条形码扫描仪将我的桌面的背景图像更改为该产品的照片。
我不知道该怎么做,我在网上找不到任何有用的信息。需要注意的是,这是针对Windows 10计算机的,而我使用的是Python 3.7。
while True:
#gives the barcode formated to be read by the program. It removes the first and last digit
barcode = str(input("Barcode: "))
reduced_barcode = str(barcode[1:-1])
#list of names in order with the barcodes list. They are placeholders for the image files I'd like to have my de3sktop background changed to
names = ['007','Crash','Metal of Honor','JakII','Battlefront']
#list of stored product barcodes
products = ['4787583429','2062671255','1463314707','1171972652','2327232835']
#checks if the scanned barcode matches the stored products barcodes and then prints the corresponding text
for i in products:
if(i == reduced_barcode):
location = products.index(i)
print(names[location])
我希望将图像文件显示为桌面背景照片,但我不知道如何实现。