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] TKinter Remove Button Frame Nu2Python 8 802 Jan-16-2024, 06:44 PM
Last Post: rob101
  [Tkinter] Help running a loop inside a tkinter frame Konstantin23 3 1,446 Aug-10-2023, 11:41 AM
Last Post: Konstantin23
  tkinter mapview in a frame janeik 2 1,238 Jun-22-2023, 02:53 PM
Last Post: deanhystad
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,005 Sep-30-2021, 05:57 PM
Last Post: menator01
  tkinter frame camera opencv Nick_tkinter 9 5,320 Mar-21-2021, 06:41 PM
Last Post: Nick_tkinter
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 5,626 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  How to disable focus on Frame in Tkinter? szafranji 1 2,967 May-13-2020, 10:45 PM
Last Post: DT2000
  [Tkinter] Is there a way to plot pandas dataframes using Plotly, with Tkinter? jbitsch 0 2,352 May-04-2020, 10:21 PM
Last Post: jbitsch
  [Tkinter] Tkinter bringing variables from 1 frame to another zukochew 6 12,399 Dec-26-2019, 05:27 AM
Last Post: skm
  Unable to put background image on Tkinter Frame jenkins43 2 8,703 Nov-27-2019, 11:38 AM
Last Post: jenkins43

Forum Jump:

User Panel Messages

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