first thanks for this great program
second i am beginner in python and tkinter i faced with this bugs when trying
to use the python 3 version of tkintertable and this my try
to fix them so if there is something wrong i am sorry for any misunderstanding
i use python 3.4.2 , windows xp
--------------------------------------------------
1-
in the first after loading the table in it's parent frame i got this error in
File Tables.py line 2143, in checkOSType
ostyp=string.lower(os.environ[var])
AttributeError: 'module' object has no attribute 'lower'
i fix it by make change from using srting to str
in line 2143 in Tables.py change the line from:
ostyp=string.lower(os.environ[var])
to:
ostyp=str.lower(os.environ[var])
-----------------------------------------
2-
the reason of this bug is moving the mouse over an empty place on the table it
raise TypeError in the handle_motion function in Table.py module in line 1032
if 0 <= row < int(self.rows) and 0 <= col < self.cols:
this happen if i move the mouse over an empty place that have no
columns in it and if we use python 2 it did't give me this error the reason
for that is in python 2 when we compare two value one of them is None like
1 < None it will give us the result of comparison False but in python 3 it
raise a TypeError so if i move the mouse over an empty place on the table
it make one of the event coordinate None so it make comparison with None type
and integer type
to fix this error i catch it through try except statement like this:
try:
if 0 <= row < int(self.rows) and 0 <= col < self.cols:
self.drawTooltip(row, col)
except TypeError:
return
return
-----------------------------------------------------------
3-
this bug raise if i specified column label bigger than 12 characters
Traceback (most recent call last):
File "F:\4\test\python\3\test.py", line 28, in <module>
set_income_table()
File "F:\4\test\python\3\test.py", line 24, in set_income_table
table.createTableFrame()
File "F:\4\test\python\3\tkintertable\Tables.py", line 218, in createTableFrame
self.redrawTable(callback=callback)
File "F:\4\test\python\3\tkintertable\Tables.py", line 330, in redrawTable
self.redrawVisible(event, callback)
File "F:\4\test\python\3\tkintertable\Tables.py", line 316, in redrawVisible
self.tablecolheader.redraw()
File "F:\4\test\python\3\tkintertable\Tables.py", line 2222, in redraw
collabel=collabel[0:int(w)/12]+'.'
TypeError: slice indices must be integers or None or have an __index__ method
in Tables.py file in line 2222 in the redraw function if the column label
is bigger than 12 character it will give me the former error the reason for
that is the division section in this line
collable=collabel[0:int(w)/12]+'.'
because the result of the division int(w)/12 will be float number in python 3
and this raise the former error so the fix to this error to change the division
to floor division or integer
division so the line will be like this:
collable=collable[0:int(w)//12]+'.'
---------------------------------------------------------------
4-
this error raise if i left click any empty space to the right of the table but
it will not appear if this empty place was down the last row it only appear if
i click the empty space to the right of table rows in the none columns space it
will raise type error like the one appear in the one i mention in number 2 and
appear like this
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "F:\4\test\python\3\tkintertable\Tables.py", line 863, in handle_left_click
if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
TypeError: unorderable types: int() <= NoneType()
and the reason for this bug is the way python 3 handle the comparisons if i
compare None with integer it will not return with false but raise a TypeError
and i fixed it by use try catch statement with the if block in code from line
862 to 871 like this:
i change it from:
if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
self.setSelectedRow(rowclicked)
self.setSelectedCol(colclicked)
self.drawSelectedRect(self.currentrow, self.currentcol)
self.drawSelectedRow()
self.tablerowheader.drawSelectedRows(rowclicked)
coltype = self.model.getColumnType(colclicked)
if coltype == 'text' or coltype == 'number':
self.drawCellEntry(rowclicked, colclicked)
return
to be like this:
try:
if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
self.setSelectedRow(rowclicked)
self.setSelectedCol(colclicked)
self.drawSelectedRect(self.currentrow, self.currentcol)
self.drawSelectedRow()
self.tablerowheader.drawSelectedRows(rowclicked)
coltype = self.model.getColumnType(colclicked)
if coltype == 'text' or coltype == 'number':
self.drawCellEntry(rowclicked, colclicked)
except TypeError:
return
return
------------------------------------------------------------------------------
5-
this bug appear if i click of Preferences menu item to show the preferences
window it will not show
the window and raise _tkinter.TclError like this:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "F:\4\test\python\3\tkintertable\Tables.py", line 1802, in showtablePrefs
self.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))
File "C:\Python34\lib\tkinter\__init__.py", line 1669, in wm_geometry
return self.tk.call('wm', 'geometry', self._w, newGeometry)
_tkinter.TclError: bad geometry specifier "+418.0+301.5"
and this one also like bug number three the reason for it is the way python 3
handle division so in showtablPrefs in Tables.py module in line 1802
self.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))
to fix it i change the divison from float divison to floor or integer division
like this
self.prefswindow.geometry('+%s+%s' %(x+w//2,y+h//2))
-----------------------------------------------------------------------
6-
this bug present if i call the File-->New context menu it will raise this
NameError
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "F:\4\test\python\3\tkintertable\Tables.py", line 2086, in new
parent=self.parentframe)
File "F:\4\test\python\3\tkintertable\Dialogs.py", line 97, in __init__
if labels != None and types != NoneType:
NameError: name 'NoneType' is not defined
the reason for it that in python 2 you use the Tkinter.NoneType that present in
the Tkinter library but and that already inhered from the type library but this
NoneType no longer exist in python 3 and also in tkinter so i fix it by calling
type(None) instead of explicit NoneType so i change line 97 in Dialogs.py
module in the __init__ method from this:
if labels != None and types != NoneType
into this:
if labels != None and types != type(None)
i got this from dive into python 3 book appendix a. Porting Code to Python 3
with 2to3
---------------------------------------------------------
and i upload the two files Tables.py and Dialogs.py after fixing this error on
them may be if you like to add them to the program for any future release and
thanks again for this great tool...
Karim Reefat
Original issue reported on code.google.com by kuda.rc...@gmail.com on 17 Feb 2015 at 2:41
Original issue reported on code.google.com by
kuda.rc...@gmail.com
on 17 Feb 2015 at 2:41Attachments: