wacom-gui icon indicating copy to clipboard operation
wacom-gui copied to clipboard

Qt5 migration

Open battlesnake opened this issue 4 years ago • 3 comments

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™

battlesnake avatar Jan 11 '20 20:01 battlesnake

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.

tb2097 avatar Jan 13 '20 18:01 tb2097

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'

ssledz avatar Aug 12 '20 13:08 ssledz

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.

oxpa avatar Feb 07 '21 22:02 oxpa