{"action":"created","issue":{"url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/15","labels_url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/15/comments","events_url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/15/events","html_url":"https://github.com/dmnfarrell/tkintertable/issues/15","id":75550234,"number":15,"title":"some bugs in python 3 version of the program and solutions to it","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dmnfarrell/tkintertable/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/dmnfarrell/tkintertable/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/dmnfarrell/tkintertable/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-12T10:20:59Z","updated_at":"2015-05-18T18:15:40Z","closed_at":"2015-05-18T18:15:40Z","body":"```\nfirst thanks for this great program \nsecond i am beginner in python and tkinter i faced with this bugs when trying \nto use the python 3 version of tkintertable and this my try \nto fix them so if there is something wrong i am sorry for any misunderstanding  \ni use python 3.4.2 , windows xp  \n--------------------------------------------------\n1-\nin the first after loading the table in it's parent frame i got this error in \nFile Tables.py line 2143, in checkOSType\n\n    ostyp=string.lower(os.environ[var])\nAttributeError: 'module' object has no attribute 'lower'\n\ni fix it by make change from using srting to str\n\nin line 2143 in Tables.py change the line from:\n\nostyp=string.lower(os.environ[var])\n\nto:\n\nostyp=str.lower(os.environ[var])\n\n-----------------------------------------\n2- \n\nthe reason of this bug is moving the mouse over an empty place on the table it \nraise TypeError in the handle_motion function in Table.py module in line 1032 \n\nif 0 <= row < int(self.rows) and 0 <= col < self.cols:\n\nthis happen if i move the mouse over an empty place that have no \ncolumns in it and if we use python 2 it did't give me this error the reason\nfor that is in python 2 when we compare two value one of them is None like \n1 < None it will give us the result of comparison False but in python 3 it\nraise a TypeError so if i move the mouse over an empty place on the table\nit make one of the event coordinate None so it make comparison with None type \nand integer type \nto fix this error i catch it through try except statement like this:\n\ntry:\n\tif 0 <= row < int(self.rows) and 0 <= col < self.cols:\n\t\tself.drawTooltip(row, col)\nexcept TypeError:\n\treturn \nreturn \n-----------------------------------------------------------\n\n3-\n\nthis bug raise if i specified column label bigger than 12 characters\n\nTraceback (most recent call last):\n  File \"F:\\4\\test\\python\\3\\test.py\", line 28, in <module>\n    set_income_table()\n  File \"F:\\4\\test\\python\\3\\test.py\", line 24, in set_income_table\n    table.createTableFrame()\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 218, in createTableFrame\n    self.redrawTable(callback=callback)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 330, in redrawTable\n    self.redrawVisible(event, callback)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 316, in redrawVisible\n    self.tablecolheader.redraw()\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 2222, in redraw\n    collabel=collabel[0:int(w)/12]+'.'\nTypeError: slice indices must be integers or None or have an __index__ method\n\nin Tables.py file in line 2222 in the redraw function if the column label \nis bigger than 12 character it will give me the former error the reason for \nthat is the division section in this line \n\ncollable=collabel[0:int(w)/12]+'.'\n\nbecause the result of the division int(w)/12 will be float number in python 3 \nand this raise the former error so the fix to this error to change the division \nto floor division or integer \ndivision so the line will be like this:\n\ncollable=collable[0:int(w)//12]+'.'\n\n---------------------------------------------------------------\n\n4-\n\nthis error raise if i left click any empty space to the right of the table but \nit will not appear if this empty place was down the last row it only appear if \ni click the empty space to the right of table rows in the none columns space it \nwill raise type error like the one appear in the one i mention in number 2 and \nappear like this\n\nException in Tkinter callback\nTraceback (most recent call last):\n  File \"C:\\Python34\\lib\\tkinter\\__init__.py\", line 1533, in __call__\n    return self.func(*args)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 863, in handle_left_click\n    if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:\nTypeError: unorderable types: int() <= NoneType()\n\nand the reason for this bug is the way python 3 handle the comparisons if i \ncompare None with integer it will not return with false but raise a TypeError \nand i fixed it by use try catch statement with the if block in code from line \n862 to 871 like this:\n\ni change it from:\n\n        if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:\n            self.setSelectedRow(rowclicked)\n            self.setSelectedCol(colclicked)\n            self.drawSelectedRect(self.currentrow, self.currentcol)\n            self.drawSelectedRow()\n            self.tablerowheader.drawSelectedRows(rowclicked)\n            coltype = self.model.getColumnType(colclicked)\n            if coltype == 'text' or coltype == 'number':\n                self.drawCellEntry(rowclicked, colclicked)\n        return\n\nto be like this:\n\n        try:\n            if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:\n                self.setSelectedRow(rowclicked)\n                self.setSelectedCol(colclicked)\n                self.drawSelectedRect(self.currentrow, self.currentcol)\n                self.drawSelectedRow()\n                self.tablerowheader.drawSelectedRows(rowclicked)\n                coltype = self.model.getColumnType(colclicked)\n                if coltype == 'text' or coltype == 'number':\n                    self.drawCellEntry(rowclicked, colclicked)\n        except TypeError:\n            return\n\n        return\n\n------------------------------------------------------------------------------\n5-\n\nthis bug appear if i click of Preferences menu item to show the preferences \nwindow it will not show\nthe window and raise _tkinter.TclError like this:\n\nException in Tkinter callback\nTraceback (most recent call last):\n  File \"C:\\Python34\\lib\\tkinter\\__init__.py\", line 1533, in __call__\n    return self.func(*args)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 1802, in showtablePrefs\n    self.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))\n  File \"C:\\Python34\\lib\\tkinter\\__init__.py\", line 1669, in wm_geometry\n    return self.tk.call('wm', 'geometry', self._w, newGeometry)\n_tkinter.TclError: bad geometry specifier \"+418.0+301.5\"\n\nand this one also like bug number three the reason for it is the way python 3 \nhandle division so in showtablPrefs in Tables.py module in line 1802 \n\nself.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))\n\nto fix it i change the divison from float divison to floor or integer division \nlike this\n\nself.prefswindow.geometry('+%s+%s' %(x+w//2,y+h//2))\n-----------------------------------------------------------------------\n6-\n\nthis bug present if i call the File-->New context menu it will raise this \nNameError \n\nException in Tkinter callback\nTraceback (most recent call last):\n  File \"C:\\Python34\\lib\\tkinter\\__init__.py\", line 1533, in __call__\n    return self.func(*args)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Tables.py\", line 2086, in new\n    parent=self.parentframe)\n  File \"F:\\4\\test\\python\\3\\tkintertable\\Dialogs.py\", line 97, in __init__\n    if labels != None and types != NoneType:\nNameError: name 'NoneType' is not defined\n\n\nthe reason for it that in python 2 you use the Tkinter.NoneType that present in \nthe Tkinter library but and that already inhered from the type library but this \nNoneType no longer exist in python 3 and also in tkinter so i fix it by calling \ntype(None) instead of explicit NoneType so i change line 97 in Dialogs.py \nmodule in the __init__ method from this:\n\nif labels != None and types != NoneType\n\ninto this:\n\nif labels != None and types != type(None)\n\ni got this from dive into python 3 book appendix a. Porting Code to Python 3 \nwith 2to3\n\n---------------------------------------------------------\n\nand i upload the two files Tables.py and Dialogs.py after fixing this error on \nthem may be if you like to add them to the program for any future release and \nthanks again for this great tool...\n\nKarim Reefat\n\n\n```\n\nOriginal issue reported on code.google.com by `kuda.rc...@gmail.com` on 17 Feb 2015 at 2:41\n\nAttachments:\n* [Tables.py](https://storage.googleapis.com/google-code-attachments/tkintertable/issue-15/comment-0/Tables.py)\n* [Dialogs.py](https://storage.googleapis.com/google-code-attachments/tkintertable/issue-15/comment-0/Dialogs.py)\n"},"comment":{"url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/comments/103153834","html_url":"https://github.com/dmnfarrell/tkintertable/issues/15#issuecomment-103153834","issue_url":"https://api.github.com/repos/dmnfarrell/tkintertable/issues/15","id":103153834,"user":{"login":"dmnfarrell","id":7859189,"avatar_url":"https://avatars.githubusercontent.com/u/7859189?v=3","gravatar_id":"","url":"https://api.github.com/users/dmnfarrell","html_url":"https://github.com/dmnfarrell","followers_url":"https://api.github.com/users/dmnfarrell/followers","following_url":"https://api.github.com/users/dmnfarrell/following{/other_user}","gists_url":"https://api.github.com/users/dmnfarrell/gists{/gist_id}","starred_url":"https://api.github.com/users/dmnfarrell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmnfarrell/subscriptions","organizations_url":"https://api.github.com/users/dmnfarrell/orgs","repos_url":"https://api.github.com/users/dmnfarrell/repos","events_url":"https://api.github.com/users/dmnfarrell/events{/privacy}","received_events_url":"https://api.github.com/users/dmnfarrell/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T18:15:40Z","updated_at":"2015-05-18T18:15:40Z","body":"You can fork this project and update it to use python 3 if you wish. It won't be backwards compatible without hassle though..."}}