Open battlesnake opened 4 years ago
Thanks for taking the time to look into this. From a quick overview it looks like for the most part I just need to change a few lines for imports, along with a few syntax changes that should be cross compatible with Python 2.7. I'll try to take a look into this further to determine exactly what is needed to limit differences between a 2.7 release and a 3.x release while still allowing me to maintain both code bases.
It doesn't work for me :(
virtualenv .env
. .env/bin/activate
pip install PyQt5
python ./wacom-gui/wacom-gui.py
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 0,0,0,100'
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 90,90,90,90'
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 0,0,0,100'
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 90,90,90,90'
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 0,0,0,100'
QCssParser::parseColorValue: Specified color without alpha value but alpha given: 'rgb 90,90,90,90'
could not convert string to float: '42,10.5'
./wacom-gui/wacom-gui.py:504: 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.btn_grp.addButton(self.buttons[(idx, 0)], idx)
./wacom-gui/wacom-gui.py:519: 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.buttonMapper.setMapping(self.buttons[(idx, 0)], idx)
could not convert string to float: '42,10.5'
Traceback (most recent call last):
File "./wacom-gui/wacom-gui.py", line 745, in <module>
main()
File "./wacom-gui/wacom-gui.py", line 737, in main
form = WacomGui()
File "./wacom-gui/wacom-gui.py", line 74, in __init__
self.refreshTablets()
File "./wacom-gui/wacom-gui.py", line 112, in refreshTablets
self.tabletSelect(0)
File "./wacom-gui/wacom-gui.py", line 303, in tabletSelect
self.setToolsAvail(idx)
File "./wacom-gui/wacom-gui.py", line 138, in setToolsAvail
self.tablet_data.tablets[self.dev][self.dev_id]['eraser']['id']]
KeyError: 'eraser'
In stylus.py:584 the command "xsetwacom --get %s area" should be called with 'text=True' attribute. In python3 popen will return you bytes instead of a string and that will break a bunch of things (like saving to json, or calling 'split' with a charater instead of a byte sequence (https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess.stdout).
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
Same goes for a couple of popens inside 'toggleDisplay' function (wacom-gui.py:666 and 676)
In wacom-gui.py:505 there is a division by 4. It will return float by default. So it's better to convert to int straight away:
idx = int(self.buttons.__len__() / 4)
In hotkeys.py:209 there is a filter statement. It produces a generator which is consumed by next line and therefore the cycle below does nothing. So the filter() may be replaced with
strokes = [i for i in re.split('{|}| ', str(cmdstring)) if i]
and then everything seems to work for me.
This runs with Python3 and PyQt5 now.
I'm not a Python dev and I'm not familiar with Qt, so it's probably not "correct", but it works for me™