Jun-26-2019, 12:37 AM
Hi all,
Thanks in advance for your help.
I have a simple tkinter gui that has two buttons: "Stop", "GO"
I am trying to loop through a pandas data frame, and for each row I would like to display a word and depending on which button is clicked (Stop or Go), I would like to append the result of the button that is clicked to the data frame for the particular index.
If possible I would like the GUI to always remain in the forefront (in front of all windows).
I have the GUI and data frame loading, but I am not sure how to combine the two.
Thanks in advance for your help.
I have a simple tkinter gui that has two buttons: "Stop", "GO"
I am trying to loop through a pandas data frame, and for each row I would like to display a word and depending on which button is clicked (Stop or Go), I would like to append the result of the button that is clicked to the data frame for the particular index.
If possible I would like the GUI to always remain in the forefront (in front of all windows).
I have the GUI and data frame loading, but I am not sure how to combine the two.
from tkinter import *
from tkinter.filedialog import askopenfilename
import pandas as pd
class Window(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.master = master
self.init_window()
def init_window(self):
self.master.title("TEST GUI")
self.pack(fill=BOTH, expand=1)
StopButton = Button(self, text="Stop", command=self.stop)
GoButton = Button(self, text="Go", command=self.go)
StopButton.place(x=25, y=25)
GoButton.place(x=25, y=80)
def stop(self):
print('stop')
def go(self):
print('go')
Tk().withdraw()
filename = askopenfilename()
if filename == '':
exit()
data = pd.read_excel(filename)
data['Stop_or_Go'] = ''
root = Tk()
root.geometry("400x300")
app = Window(root)
for index, series in data.iterrows():
word_of_day = series['Word']
#this is where I want the to be able to click Stop or Go
data.at[index, 'Stop_or_Go'] = #GUI BUTTON RESPONSE
root.mainloop()
