dmnfarrell / tkintertable

A pure Python library for adding tables to a Tkinter application
Other
396 stars 107 forks source link

Long text getting truncated in table view #32

Open Meandmore opened 6 years ago

Meandmore commented 6 years ago

I'm attempting to get long text to appear in a cell. From the data file:

capture1

The text has embedded newlines (0x0a) which appear to work,

capture2

and the data appears to be going into the model correctly,

capture2

but (as seen in the second and third images) the displayed info is being truncated. Is there anything that can be done with that?

dmnfarrell commented 6 years ago

It doesn't support wrapping as such. I think the truncation is done in the drawText method https://github.com/dmnfarrell/tkintertable/blob/master/tkintertable/Tables.py
I don't actively make updates to this library but if you can change it in a way that doesn't break normal behaviour I would be glad to integrate the code.

Meandmore commented 6 years ago

Here's line 1634 [in drawText()]: celltxt = celltxt[0:int(math.floor(newlength))]

There should be no trouble partitioning around newlines, but the height of the cell will now have to be considered. I haven't used tkintertable long enough -- is there only one row height for the whole table? If so, then either all rows might be height-increased; or the font size can be decreased; or the text is truncated but not until the height is filled. I suspect the first two are non-starters.

While not optimal for me, if the text can be extended that would be better than nothing. (BTW, I'm not suggesting an automatic wrap - the user would have to provide embedded newlines in the text to create multiple lines in the cell.)

Are you OK with any of those options?

dmnfarrell commented 6 years ago

Yes there is a single global row height and font size. These can be changed in the prefs dialog. The text length is meant to be truncated to fit the column but seems isn't accurately calculated anyway. A proper wrap would be best rather than a hack based on newlines but I realise it would take time to implement. Any solution that doesn't break the normal behaviour is ok. You might be better off subclassing the table and implementing your own drawText that doesn't truncate.

Note that I implemented wrapping in pandastable but just for the column header ( http://dmnfarrell.github.io/dataexplore/2018/06/21/newrelease-0.10). So the code in there might be of use also. see https://github.com/dmnfarrell/pandastable/blob/master/pandastable/headers.py

alex-pancho commented 5 years ago

I download last version, but i have seems problem: screen Did you can help fix it?

dmnfarrell commented 5 years ago

The table can't deal with non ascii characters very well. You are using cyrilic? I'll have to see how easy it is to fix.

alex-pancho commented 5 years ago

it is unicode encoding, but yes, it is cyrillic. or maybe its cp1251 -Widows Cyrillic

i have some other question about tkintertable, if you can help - it was amazing! my e-mail is pan.pan.4it@gmail.com

MRES1 commented 4 years ago

I'm attempting to get long text to appear in a cell. From the data file:

capture1

The text has embedded newlines (0x0a) which appear to work,

capture2

and the data appears to be going into the model correctly,

capture2

but (as seen in the second and third images) the displayed info is being truncated. Is there anything that can be done with that?

I need to get values truncated otherwise it looks really bad for my purposes how did you make that happen?

image

MRES1 commented 4 years ago

The text length is meant to be truncated to fit the column but seems isn't accurately calculated anyway.

I think you know my problem ... what should be the solution to make this calculation more accurate? image