Python Forum
TKinter GUI / Pandas Data frame Loop
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 230 Sep-30-2021, 05:57 PM
Last Post: menator01
  tkinter frame camera opencv Nick_tkinter 9 1,414 Mar-21-2021, 06:41 PM
Last Post: Nick_tkinter
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 1,776 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  How to disable focus on Frame in Tkinter? szafranji 1 1,336 May-13-2020, 10:45 PM
Last Post: DT2000
  [Tkinter] Is there a way to plot pandas dataframes using Plotly, with Tkinter? jbitsch 0 1,155 May-04-2020, 10:21 PM
Last Post: jbitsch
  [Tkinter] Tkinter bringing variables from 1 frame to another zukochew 6 7,081 Dec-26-2019, 05:27 AM
Last Post: skm
  Unable to put background image on Tkinter Frame jenkins43 2 6,682 Nov-27-2019, 11:38 AM
Last Post: jenkins43
  Active tkinter text output during loop dvanommen 2 6,288 Oct-18-2019, 02:23 PM
Last Post: dvanommen
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 5,667 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [python][tkinter][pandas] NEL 0 1,471 Aug-05-2019, 12:16 PM
Last Post: NEL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020