this is example of my code – im using tkinter with tabs and pandas table inside.
when im trying to insert data to a cell in the first tab im getting error
`
import pandas as pd
from pandastable import Table
import tkinter as tk
from tkinter import ttk
class PandasTableApp(tk.Tk):
def __init__(self):
super().__init__()
self.title("PandasTable in Tabs")
self.geometry("800x600")
# Sample DataFrames
data1 = {'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]}
df1 = pd.DataFrame(data1)
data2 = {'X': [10, 20, 30], 'Y': [40, 50, 60], 'Z': [70, 80, 90]}
df2 = pd.DataFrame(data2)
# Create Tab Control
tab_control = ttk.Notebook(self)
tab1 = ttk.Frame(tab_control)
tab2 = ttk.Frame(tab_control)
tab_control.add(tab1, text='Tab 1')
tab_control.add(tab2, text='Tab 2')
tab_control.pack(expand=1, fill='both')
# Create PandasTable instances
self.table1 = Table(tab1, dataframe=df1)
self.table2 = Table(tab2, dataframe=df2)
self.table1.show()
self.table2.show()
# Bind events for each table
self.table1.bind("<Return>", self.handle_return_table1)
self.table2.bind("<Return>", self.handle_return_table2)
def handle_return_table1(self, event):
# Custom handler for the Enter key event for table1
self.table1.handle_arrow_keys(event)
return "break"
def handle_return_table2(self, event):
# Custom handler for the Enter key event for table2
self.table2.handle_arrow_keys(event)
return "break"
if __name__ == "__main__":
app = PandasTableApp()
app.mainloop()`
this is the error i get:
C:UsersxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py:1884: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set pd.set_option('future.no_silent_downcasting', True)
return self.func(*args)
C:UsersxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py:1884: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set pd.set_option('future.no_silent_downcasting', True)
return self.func(*args)
C:UsersxxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py:1884: FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior, set pd.set_option('future.no_silent_downcasting', True)
return self.func(*args)
C:UsersxxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py:1884: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use ser.iloc[pos]
return self.func(*args)
C:UsersxxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py:1884: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value ‘2’ has dtype incompatible with int64, please explicitly cast to a compatible dtype first.
return self.func(*args)
Exception in Tkinter callback
Traceback (most recent call last):
File “C:UsersxxxxxAppDataLocalProgramsPythonPython39libtkinter_init_.py”, line 1884, in call
return self.func(*args)
File “C:UsersxxxxxDesktopxxxx-xxxxxx-venvlibsite-packagespandastablecore.pyy”, line 2350, in handle_arrow_keys
x,y = self.getCanvasPos(self.currentrow, self.currentcol-1)
File “C:UsersxxxxxDesktopxxxx-xxxxxx-venvlibsite-packagespandastablecore.py”, line 2151, in getCanvasPos
x1,y1,x2,y2 = self.getCellCoords(row,col)
File “C:UsersxxxxxDesktopxxxx-xxxxxx-venvlibsite-packagespandastablecore.py”, line 2140, in getCellCoords
x1=self.col_positions[col]
IndexError: list index out of range
when i write to the 2nd tab it works – im able to write to cell there.
but writing to the firs tab crash and send this error.
any idea why its occured?
thanks in advance.