How to run both input() and buttons() at the same time? Preferably with no libraries.
from threading import*
from asyncio import*
from multiprocessing import*
from time import*
from tkinter import*
yhealth = 0
def onButton(n):
global m
if n == 0:
return m
else:
m = n
return n
def buttons():
sleep(1)
main = Tk()
main.geometry('250x50')
Att = Button(main, text = 'Attack', command = lambda:(onButton(1), main.destroy()), fg = 'red')
Att.pack(side = LEFT)
Reg = Button(main, text = 'Regen', command = lambda:(onButton(2), main.destroy()), fg = 'red')
Reg.pack(side = LEFT)
Rock = Button(main, text = 'Attack', command = lambda:(onButton(3), main.destroy()))
Rock.pack(side = RIGHT)
Shield = Button(main, text = 'Shield', command = lambda:(onButton(4), main.destroy()), fg = 'blue')
Shield.pack(side = RIGHT)
main.mainloop()
def inputchoose():
global chosenmove
chosenmove = 0
chosenmove = int(input('Choose 1/2/3/4'))
if chosenmove == (1 or 2 or 3 or 4):
return chosenmove
return(chosenmove)
def movetell():
global yhealth
ymove = 0
inputchoose(), buttons() ##this part doesn't work, it waits for input to close, and only then turns on #buttons
while True:
if buttons() != None:
ymove = str(buttons())
print('lol')
break
if inputchoose() != None:
print('lol.')
ymove = str(inputchoose())
break
#remaking the entire code in general would be nice as well, tysm
I've tried many variations, but none of it works, so I'm hopeless.