Added fix canvas.py for python3 #11

Merged
MicheleC merged 1 commits from feat/exampleCanvas into master 2 years ago
Collaborator

I noticed that the canvas.py example is not working.
I propose a fix for python3. In python3 True and False are constants and cannot be overridden. Changes have also been made where explicit casting of a real type to an integer is required. Explicit integer arithmetic is now used where appropriate.

I noticed that the canvas.py example is not working. I propose a fix for python3. In python3 `True` and `False` are constants and cannot be overridden. Changes have also been made where explicit casting of a real type to an integer is required. Explicit integer arithmetic is now used where appropriate.
ormorph added 1 commit 2 years ago
469316aca3
Added fix canvas.py for python3
Owner

Hi @ormorph,
the PR seems good, but I can't test here in debian + PTB. It seems there are other issues with where files are installed in debian.

@aneejit1 if you could test and confirm everything is fine with this PR, I will then merge it.

Hi @ormorph, the PR seems good, but I can't test here in debian + PTB. It seems there are other issues with where files are installed in debian. @aneejit1 if you could test and confirm everything is fine with this PR, I will then merge it.
Owner

Do not forget that we have to test the examples in both versions of Python.

Do not forget that we have to test the examples in both versions of Python.
Poster
Collaborator

Do not forget that we have to test the examples in both versions of Python.

Hmm, I didn't use incompatible functions. All this math will work in python2 as well. In python2 True and False are variables, but if they were not declared, then their meanings are the same.
Out in Python2.7:

>>> int(True)
1
>>> int(False)
0

I rechecked all the parameters, now there is a defect to be corrected in View->Enlarge and View->Shrink.
Out:

/home/ormorph/program/GIT/python-tqt/examples/canvas/canvas.py:312: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.canvas.resize(self.canvas.width()*4/3, self.canvas.height()*4/3)
/home/ormorph/program/GIT/python-tqt/examples/canvas/canvas.py:315: DeprecationWarning: an integer is required (got type float).  Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python.
  self.canvas.resize(self.canvas.width()*3/4, self.canvas.height()*3/4)

Now I will transfer it to integer calculations, and in principle it will be possible to merge.

> Do not forget that we have to test the examples in both versions of Python. Hmm, I didn't use incompatible functions. All this math will work in python2 as well. In python2 True and False are variables, but if they were not declared, then their meanings are the same. Out in Python2.7: ``` >>> int(True) 1 >>> int(False) 0 ``` I rechecked all the parameters, now there is a defect to be corrected in View->Enlarge and View->Shrink. Out: ``` /home/ormorph/program/GIT/python-tqt/examples/canvas/canvas.py:312: DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python. self.canvas.resize(self.canvas.width()*4/3, self.canvas.height()*4/3) /home/ormorph/program/GIT/python-tqt/examples/canvas/canvas.py:315: DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using __int__ is deprecated, and may be removed in a future version of Python. self.canvas.resize(self.canvas.width()*3/4, self.canvas.height()*3/4) ``` Now I will transfer it to integer calculations, and in principle it will be possible to merge.
Owner

Do not forget that we have to test the examples in both versions of Python.

@SlavekB: are you able to run examples in python3 in your system? I tried here and it seems the dist packages for python3 are not installed in the right place (or not installed at all). Haven't spent time on it yet, so just asking aforehead.

Long term, we should drop support for python2 anyway

> Do not forget that we have to test the examples in both versions of Python. @SlavekB: are you able to run examples in python3 in your system? I tried here and it seems the dist packages for python3 are not installed in the right place (or not installed at all). Haven't spent time on it yet, so just asking aforehead. Long term, we should drop support for python2 anyway
ormorph force-pushed feat/exampleCanvas from 469316aca3 to 4af88a8c9d 2 years ago
Poster
Collaborator


Made corrections, now there are no warnings. Unfortunately, on python2 I am missing an assembly. If someone can check this in python2, then that would be good.

[<img src="https://i.postimg.cc/02FGS80Q/picture12.png" title="canvas.py" width="550" />](https://i.postimg.cc/02FGS80Q/picture12.png) Made corrections, now there are no warnings. Unfortunately, on python2 I am missing an assembly. If someone can check this in python2, then that would be good.
Poster
Collaborator

To build the latest python-tqt, sip4-tqt no longer uses the <python_site>/sip4_tqt path, it is now just <python_site>. The old sip4-tqt build method is no longer working. The build options for the python-tqt package have not changed.
At the moment, building with python2 support on Gentoo is quite problematic, so I didn't add this package to the Gentoo overlay earlier.As of version 14.0.13, thanks to the latest changes, it is now possible to add this. A build is currently available for the live branch only.

To build the latest python-tqt, sip4-tqt no longer uses the `<python_site>/sip4_tqt` path, it is now just `<python_site>`. The old sip4-tqt build method is no longer working. The build options for the python-tqt package have not changed. At the moment, building with python2 support on Gentoo is quite problematic, so I didn't add this package to the Gentoo overlay earlier.As of version 14.0.13, thanks to the latest changes, it is now possible to add this. A build is currently available for the live branch only.
ormorph force-pushed feat/exampleCanvas from 4af88a8c9d to 223af3b47f 2 years ago
Poster
Collaborator

Added latest changes. Now python2.7 is also normally supported. Tested with python2.7 on raspberry pi4. I have version 14.0.12 on my raspberry pi4, I checked it on it.
There is no point in adding ebuilds to the Gentoo overlay, as they are not compatible with the python2 version. For now, I'll wait for the release of version 14.0.13.
I could not find any errors, so I think you can merge.

Added latest changes. Now python2.7 is also normally supported. Tested with python2.7 on raspberry pi4. I have version 14.0.12 on my raspberry pi4, I checked it on it. There is no point in adding ebuilds to the Gentoo overlay, as they are not compatible with the python2 version. For now, I'll wait for the release of version 14.0.13. I could not find any errors, so I think you can merge.
Owner

I can confirm it works fine on python2 in debian.

I can confirm it works fine on python2 in debian.
MicheleC merged commit 223af3b47f into master 2 years ago
MicheleC deleted branch feat/exampleCanvas 2 years ago
MicheleC added this to the R14.0.13 release milestone 2 years ago
The pull request has been merged as 223af3b47f.
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: TDE/pytqt#11
Loading…
There is no content yet.