Comments (2)
I have the same question that I have some problems using the autoResizeColumns()
. I have figured it out and rewrote corresponding code in my local files. Here is the resolution (not for everyone!).
autoResizeColumns()
is called when you use self.table.show()
so you don't need to call it after drawing. The bug actually comes from tkintertable.TableModels.getlongestEntry()
. In this method it assumes all characters takes the same horizontal space, which is not always. If you are using Chinese characters or some other Asian language in you table, each of them takes 2 or more times of space of English characters do. I am actually using Chinese so I rewrite tkintertable.TableModels.getlongestEntry()
like this
def getlongestEntry(self, columnIndex):
"""Get the longest cell entry in the col"""
collist = self.getColCells(columnIndex)
maxw=5
for c in collist:
try:
w = 0
for ch in str(c):
if '\u4e00' <= ch <= '\u9fff': #most Chinese characters are between those in Unicode
w += 2
else:
w += 1
print(w)
except UnicodeEncodeError:
pass
if w > maxw:
maxw = w
#print 'longest width', maxw
return maxw
Hope this helps you. Plus, sincerely thankyou to @dmnfarrell for the wonderful module.
from tkintertable.
Thanks for the code @ACE0PERFECT. As always I recommend people subclass the Table and/or TableModel and override the methods there.
from tkintertable.
Related Issues (20)
- cell binding HOT 7
- GPL or copyright? HOT 1
- Solved: Is it possible to make readonly just a single column ?
- rowspan and colspan HOT 1
- Values on table overlapping (Visual overlapping) HOT 1
- Draw Text does not work. HOT 1
- importCSV doesnt work HOT 2
- sys is not defined HOT 6
- isLink function in Tables.py logic issue HOT 2
- No Way to add several columns at ones HOT 1
- Left clicking bug
- Bug in `TableModel.deleteColumns()`
- Omit filter term in model.getColumnData
- Freezepane HOT 1
- Question on Data type HOT 1
- No Option to Insert Images Into TkinterTable? HOT 2
- Usage doc problem
- ListType outdated
- Output: "Did not find preferences!!!" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tkintertable.