I have a working program for sorting some screws using computer vision. Now I want to make a user-interface using tkinter. I am trying to keep the tkinter
file and my program file separate, but I have problems with making my user inputs work.
As you see below i have a input
function where the user can write "run"
or "not"
in the console to make the program start:
#This is just a part of my function in the program file
while True:
#Ask if user will run the program
yesOrNo = input('\nrun or not\n')
if yesOrNo == 'run':
break
elif yesOrNo == 'not':
print('programmet stoppes')
quit()
else:
print('use only "run" or "not"')
The trouble begins when i call my function in the tkinter file using a button. Because when I have started the function I don't know how to interact with the function. I have tried using an Entry() and then replace my input()
with entry.get()
, but this crashes my tkinter, because the entry.get()
, doesn't wait for the user to write something and therefore keeps running the while
loop.
So summed up I just want something that acts like the input()
and waits for the user to click enter or a button and then my function has to get this value while running (therefore I can't put the value as an parameter in the function).
I want the input field to be inside my tkinter root
and therefore I don't want to use tkinter.simpledialog.askstring()
.
I am not good at global variables, but is that a way to go? Like making a global variable inside my tkinter file which somehow can be read by my function (from the other file) while running. And then changing the value of the variable with a button or so.