Giter Club home page Giter Club logo

Comments (7)

dmnfarrell avatar dmnfarrell commented on July 30, 2024

You'll have to give me an example of what you're trying to do.

from tkintertable.

nanduOO5 avatar nanduOO5 commented on July 30, 2024

Here I am trying to read a file from the user which can only be a spreadsheet. When I am trying to edit the cells they just revert back to their original state. I need to them to be in the changed state and can you also suggest me how to reflect the same changes in the file from which the values are being displayed.

from tkintertable import TableCanvas, TableModel
from tkintertable import *
from tkinter import *
from xl2dict import *

filepath = ''
def openFile(event=None):
global filepath
filepath = filedialog.askopenfilename(filetypes=[('Excel files','.xlsx'),('Excel 2009 files','.xlx'),('CSV files','*.csv')])
displayTables(filepath)

def displayTables(filepath):
master = Tk()
master.geometry("1024x720")
master.title('Spreadsheet UI')
obj = XlToDict()
a2d = obj.convert_sheet_to_dict(file_path=filepath)

data = {}
for i in range(0,len(a2d)):
        data.update({str(i):a2d[i]})
        
tframe = Frame(master)
tframe.pack(fill=BOTH,expand=1)
table = TableCanvas(tframe,data=data)
model = table.model
model.importDict(data)
#table.redraw()
table.show()
master.mainloop()

open_win = Tk()
open_win.geometry("200x100")
open_win.title("Spreadsheet UI")
btn = Button(open_win,text="Import file",command = openFile)
btn.pack()

from tkintertable.

dmnfarrell avatar dmnfarrell commented on July 30, 2024

You must not be updating the dict the way you need to. It doesn't look to me like you're doing anything to change it. setting data.update({str(i):a2d[i]}) just copies the other dict?

from tkintertable.

nanduOO5 avatar nanduOO5 commented on July 30, 2024

I have not done anything to update the dictionary. I can not understand how to retrieve the updated values from the cells. If I can understand that then I will something about updating the values. I need help with retrieving the values from the cells.

from tkintertable.

dmnfarrell avatar dmnfarrell commented on July 30, 2024

You should be able to retrieve the cell values this way:

data = table.model.data
cols = table.model.columnNames #get the current columns
value = data[row][col]

from tkintertable.

nanduOO5 avatar nanduOO5 commented on July 30, 2024

How would I know which row or col is updated by the user? That's the problem.

from tkintertable.

dmnfarrell avatar dmnfarrell commented on July 30, 2024

Maybe you could sub-class the table and override the drawCellEntry method and run the code you need inside that method.

from tkintertable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.