Hello everyone,
I have a question:
How can a button's function run only when the button is clicked?
I am using tkinter.
All I want is to import(give me) the data from the user and do it with some buttons something like:
Button1==> Keys
Button2==> Give/Ghange Position
Button3==> Find Keys
Button4==> Kitchen
So, I want when the user click on Button1(Keys)..When choose if he want to give or find the keys (Buttons 2 or 3)..and when if he clicked on Button2...give the keys' position(e.x. click on Button4) or if he clicked on Button3 print the keys position(e.x. Kitchen=Button4)
Is it applicable or I have to import(give me) the data in another way??
My main project is to help people who suffer from alzheimer disease.
My code is below (in my class):
The problem is that python runs the buttons' commands before buttons clicked.So, x,y have already their values and "response" has the value of "Give" because the command is later in the code (I am not sure about this..)
Thanks in advance.
I have a question:
How can a button's function run only when the button is clicked?
I am using tkinter.
All I want is to import(give me) the data from the user and do it with some buttons something like:
Button1==> Keys
Button2==> Give/Ghange Position
Button3==> Find Keys
Button4==> Kitchen
So, I want when the user click on Button1(Keys)..When choose if he want to give or find the keys (Buttons 2 or 3)..and when if he clicked on Button2...give the keys' position(e.x. click on Button4) or if he clicked on Button3 print the keys position(e.x. Kitchen=Button4)
Is it applicable or I have to import(give me) the data in another way??
My main project is to help people who suffer from alzheimer disease.
My code is below (in my class):
Code:
self.button3=Button(master,text='Keys',command=self.keyss).pack()
self.button5=Button(master,text='Search',command=self.klik_search).pack()
self.button4=Button(master,text='Give',command=self.klik_give).pack()
self.button6=Button(master,text='Kitchen',command=self.kitchenn).pack()
a={}
if response=='Give':
a[x]=y # add to dictionary
#self.lav2=Label(master,text=y).pack()
elif response=='Search':
for i in a:
if i==x:
self.lav=Label(master,text=y).pack()
def keyss(self):
global x
x='Keys'
def kitchenn(self):
global y
y='Kitchen'
def klik_give(self):
global response
response='Give'
def klik_search(self):
global response
response='Search'
Thanks in advance.