+ 1

insert an image

How to insert an image into a Python. When you press one number a certain image appears and when you press two, another image appears??

16th May 2018, 5:56 AM
Mustafa Ali
Mustafa Ali - avatar
4 odpowiedzi
+ 2
Working code for windows machines: import os from msvcrt import getch img1 = "[image path here]" img2 = "[image path here]" def capturekey(): key = ord(getch()) return showimg(key) def showimg(key): if key == 49: #keyboard number 1 os.system(img1) elif key == 50: #keyboard number 2 os.system(img2) elif key == 51: #keyboard number 3 exit() else: print("invalid key") while True: capturekey() if you need them to appear in a single window, then you should consider applying this code into tkinter image function
16th May 2018, 7:45 PM
Markus Kaleton
Markus Kaleton - avatar
0
This is all I can do now, this answer is about how it would work on Pydroid 3: code: >>> def Add(X): if X == "1": return 1 elif X == "2": return 2 else: return "Program ended" while True: x = Add(input("Type number 1 or 2")) if x == "Program ended": print(x) break else: print(x) >>> you can use Terminal to search and edit files, so I also give you terminal commands: pwd = print working directory ls = list cd <foldername> = check directory mkdir <foldername> = make directory rmdir <foldername> = remove directory touch <filename> create file rm <filename>  remove file cd .. = check previous directory cd ../.. = check home directory clear = clear termin
16th May 2018, 8:22 AM
Seb TheS
Seb TheS - avatar
0
You might need to use some modules to use images
16th May 2018, 10:37 AM
Seb TheS
Seb TheS - avatar
0
I'll look into this. will comment more later
16th May 2018, 1:46 PM
Markus Kaleton
Markus Kaleton - avatar