Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float or Datetime cell creates Error #56

Open
jamesbeerbower opened this issue May 24, 2019 · 1 comment
Open

Float or Datetime cell creates Error #56

jamesbeerbower opened this issue May 24, 2019 · 1 comment

Comments

@jamesbeerbower
Copy link

jamesbeerbower commented May 24, 2019

Thanks for what you are doing! Apologies in advance if I'm on drugs!

Describe the bug
Float or Datetime data causes error in drawText.

File "D:\development\common\python\test_gui\venv\lib\site-packages\tkintertable\Tables.py", line 1690, in drawText
length = len(celltxt)
TypeError: object of type 'datetime.datetime' has no len()

To Reproduce
from tkintertable import TableCanvas, TableModel
from tkinter import *
from datetime import datetime
import random
from collections import OrderedDict

data = {'rec1': {'col1': 100, 'col2': 108.79, 'label': 'rec1'},
'rec2': {'col1': datetime.now(), 'col2': 321.79, 'label': 'rec3'},
'rec3': {'col1': 29.88, 'col2': 408.79, 'label': 'rec2'}
}

#from tkintertable.Testing import sampledata
#data=sampledata()
#print(data)

class TestApp(Frame):
"""Basic test frame for the table"""

def __init__(self, parent=None):
    self.parent = parent
    Frame.__init__(self)
    self.main = self.master
    self.main.geometry('800x500+200+100')
    self.main.title('Test')
    f = Frame(self.main)
    f.pack(fill=BOTH,expand=1)
    table = TableCanvas(f, data=data)
    #table.importCSV('test.csv')
    print (table.model.columnNames)
    #table.model.data[1]['a'] = 'XX'
    #table.model.setValueAt('YY',0,2)
    table.show()
    return

app=TestApp()
app.mainloop()

System

Operating system: Windows
Python version: 3.6
Installation method (pip, git clone): pip

@hannansatopay
Copy link
Contributor

Hello @jamesbeerbower
Here is a simple fix: Wrap the datetime.now() call in a string like this - str(datetime.now())

I have tested it and it works without any issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants