Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 TKinter GUI / Pandas Data frame Loop
#1
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.


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()

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Tkinter bringing variables from 1 frame to another zukochew 6 2,866 Dec-26-2019, 05:27 AM
Last Post: skm
  Unable fetch fucntion data in class in tkinter jenkins43 2 304 Nov-30-2019, 09:47 PM
Last Post: jenkins43
  Unable to put background image on Tkinter Frame jenkins43 2 879 Nov-27-2019, 11:38 AM
Last Post: jenkins43
  Active tkinter text output during loop dvanommen 2 980 Oct-18-2019, 02:23 PM
Last Post: dvanommen
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 1,496 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] Plotting Raster Data / TIFF files on tkinter canvas RRSCNGP 0 322 Aug-28-2019, 04:44 AM
Last Post: RRSCNGP
  [python][tkinter][pandas] NEL 0 435 Aug-05-2019, 12:16 PM
Last Post: NEL
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 1,657 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] New to Tkinter -- Does not recognize "Frame" as attribute. cwatt1 2 1,488 Jan-03-2019, 03:13 PM
Last Post: cwatt1
  [Tkinter] loop function when called from tkinter button click WantedStarling 5 2,833 Jul-13-2018, 06:12 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)