Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py3 qt5 el8 #64

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.py]
indent_style = space
indent_size = 4

[*.ui]
indent_style = space
indent_size = 2

[*.json]
indent_style = tab
indent_size = 4


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__/
.pyc
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# I've hacked this to run with Python 3 and PyQt5.

I'm not a Python developer, so don't expect the migration to look pretty.

Also fixed a bug in scanning for `Name=` key, which was preventing one of my tablets from being detected.

# wacom-gui

Python/PyQt Wacom GUI for MATE/KDE
Expand All @@ -9,7 +15,7 @@ These instructions will help you get a copy of the project up and running on yor

### Prerequisites
You will require a few packages to get this working on your system:
- PyQt4
- PyQt5

### Installing
- Running from source
Expand Down
2 changes: 1 addition & 1 deletion rpmbuild/wacom-gui
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

script="/usr/local/wacom-gui/wacom-gui.py"

exec /usr/bin/python "$script" "$@"
exec /usr/bin/python3 "$script" "$@"
27 changes: 13 additions & 14 deletions rpmbuild/wacom-gui.spec
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
%global libwacom_ver 1.11
%global libwacom_ver 2.2.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On EL8 I currently get a libwacom-1.6-3.el8.x86_64 - don't know whatever the version is important here?


Name: wacom-gui
Version: 0.3.1
Release: rc1
Summary: Wacom PyQt4 GUI
Version: 0.4.0
Release: rc2
Summary: Wacom PyQt5 GUI
License: GPLv3
BuildArch: noarch
URL: https://github.com/tb2097/wacom-gui
Requires: PyQt4
Requires: PyQt4-webkit
Requires: qtwebkit
Requires: PyQt5
Requires: libwacom
Requires: xorg-x11-server-utils
Requires: xorg-x11-drv-wacom
Requires: xorg-x11-xkb-utils
Requires: xorg-x11-utils
Requires: dconf
Requires: usbutils
Requires: python
Requires: python3
Requires: systemd
BuildRequires: python
Source0: %{name}-%{version}-%{release}.tar.xz
BuildRequires: python3
Source0: %{name}-%{version}-%{release}.tar.gz
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure whatever you want a .gz or .xz tarball here

# latest libwacom source can be downloaded from https://github.com/linuxwacom/libwacom/releases/latest
# this is just to get the .tablet and svg data
Source1: libwacom-%{libwacom_ver}.tar.bz2
Source1: libwacom-%{libwacom_ver}.tar.xz
Source2: wacom.desktop

%description
Wacom PyQt4 GUI
Wacom PyQt5 GUI

%prep
%setup -q -n %{name}-%{version}-%{release}
Expand All @@ -36,7 +35,7 @@ Wacom PyQt4 GUI
cd wacom-gui
rm -f *.pyc
rm -f *.ui
python -m compileall .
python3 -m compileall .
mv ../LICENSE .
mv ../README.md .
mkdir data
Expand All @@ -47,7 +46,7 @@ rm -f data/layouts/Makefile.*

%install
%__rm -rf %{buildroot}
cd wacom-gui
cd wacom-gui/wacom-gui
install -m 0755 -d %{buildroot}/usr/local/%{name}
cp -r * %{buildroot}/usr/local/%{name}
cd ../rpmbuild
Expand Down
6 changes: 3 additions & 3 deletions wacom-gui/help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
#!/usr/bin/env python3

from PyQt4 import QtWebKit
from PyQt4 import QtCore, QtGui
from PyQt5 import QtWebKit
from PyQt5 import QtCore, QtGui
import sys, os, re

class Help(QtGui.QWidget):
Expand Down
11 changes: 6 additions & 5 deletions wacom-gui/hotkeys.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from functools import partial
import json
import os
Expand Down Expand Up @@ -203,7 +204,7 @@ def get_keystroke(self, runcmd):
json.dump(self.keymap_custom, fout, sort_keys=True, indent=4, separators=(',', ": "))

def xsetcmd_gen(self, cmdstring):
strokes = filter(None, re.split('{|}| ', str(cmdstring)))
strokes = [i for i in re.split('{|}| ', str(cmdstring)) if i]
self.cmd = ' '.join(strokes)
xsetcmd = ''
button = False
Expand Down Expand Up @@ -661,7 +662,7 @@ def __init__(self, devid, blabel, bid, cmd):
self.button = Hotkey(devid, blabel, bid, cmd)
self.layout = QVBoxLayout(self)
self.layout.setAlignment(Qt.AlignLeft)
self.layout.setMargin(0)
# self.layout.setMargin(0)
self.layout.addWidget(self.button.btn)
self.layout.addWidget(self.button.label)
self.setMaximumSize(120, 40)
Expand Down
30 changes: 15 additions & 15 deletions wacom-gui/kde_shortcut.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: Copyright © 2021 Jason Gerecke <[email protected]>
# SPDX-License-Identifier: MIT
Expand Down Expand Up @@ -181,7 +181,7 @@ def _kde5ConfigPath():
def _kdeConfigPath(version=None):
"""
Return a configuration path for an arbitrary KDE version.

This function tries to be clever about detecting the most likely
path intended. You can request a specific version by providing it
as an argument. This function will raise an exception if no version
Expand Down Expand Up @@ -232,11 +232,11 @@ def _dumpKhotkeysRc():
class _KdeConfigParser(configparser.RawConfigParser):
"""
Custom configuration parser designed for KDE files.

This parser extends the RawConfigParser with necessary default options
and some convenience functions.
"""

def __init__(self):
configparser.RawConfigParser.__init__(self, allow_no_value = True)
self.optionxform = str
Expand Down Expand Up @@ -272,7 +272,7 @@ def write(self, fileobj):
def _addShortcutSection(data, parent, value):
"""
Create a new "Data_{N}" section for a khotkeys shortcut.

This function takes a dictionary of values and assigns them to a
new "Data_{N}" section of the khotkeys configuration. This function
takes care of updating the number of declared data sections and
Expand Down Expand Up @@ -315,7 +315,7 @@ def _addShortcutSection(data, parent, value):
def _addShortcutSubsection(data, ident, subsection, value):
"""
Create a new "Data_{N}{Foo}" subsection for a khotkeys shortcut.

This function takes a dictionary of values and assigns them to a
new "Data_{N}{Foo}" section of the khotkeys configuration. This
function takes care of updating the number of declared {Foo}
Expand Down Expand Up @@ -352,7 +352,7 @@ def _addShortcutSubsection(data, ident, subsection, value):
def _addShortcut(data, parent, name, command, shortcut, comment):
"""
Add a new shortcut into the khotkeys configuration.

This function creates the multiple sections of khotkeys configuration
which define a keyboard shortcut that launches a command. No validation
is performed to check for other conflicting shortcuts; you should
Expand Down Expand Up @@ -393,7 +393,7 @@ def _addShortcut(data, parent, name, command, shortcut, comment):
def getShortcutData(data, ident):
"""
Try to return basic information about the requested khotkeys shortcut.

Looks for the provided identifier in the khotkeys configuration and
returns information about the shortcut, if possible. If the identifier
could not be found or it does not correspond to a simple command-launching
Expand All @@ -418,7 +418,7 @@ def getShortcutData(data, ident):
actions_name = "{}Actions".format(section_name)
triggers_name = "{}Triggers".format(section_name)
conditions_name = "{}Conditions".format(section_name)

if section_name not in data:
return None
section_data = data[section_name]
Expand Down Expand Up @@ -451,7 +451,7 @@ def getShortcutData(data, ident):
def _findShortcut(data, name = None, shortcut = None, uuid = None):
"""
Search the provided khotkeys dict for a matching shortcut.

This function searches through the khotkeys configuration for any
shortcut which matches all of the provided paramters. Any parameter
may be ignored by providing 'None' as its value.
Expand Down Expand Up @@ -503,7 +503,7 @@ def _findShortcut(data, name = None, shortcut = None, uuid = None):
def _createShortcut(name, command, shortcut, comment=''):
"""
Create a new shortcut in the khotkeys configuration.

This function will attempt to add a new shortcut into the khotkeys
file. It will check to ensure the shortcut does not already exist
first (no other shortcut may share its name or keyboard sequence).
Expand Down Expand Up @@ -538,15 +538,15 @@ def _createShortcut(name, command, shortcut, comment=''):

uuid = _addShortcut(data, '', name, command, shortcut, comment)
parser.read_dict(data)

with open(config_path + ".tmp", 'w') as output:
parser.write(output)
return uuid

def _createGlobal(shortcut_uuid, name, shortcut):
"""
Create a new hotkey shortcut in the kglobalshortcutsrc config file.

This function will attempt to add a new khotkeys shortcut into the
kglobalshortcutsrc file. It does not perform any checking if the
shortcut is already in use.
Expand All @@ -572,7 +572,7 @@ def _createGlobal(shortcut_uuid, name, shortcut):
def create(name, command, shortcut, comment):
"""
Create a new shortcut in the necessary KDE config files.

This function will attempt to add a new shortcut into the two config
files that control custom user shortcuts.

Expand Down Expand Up @@ -603,7 +603,7 @@ def create(name, command, shortcut, comment):
def activate():
"""
Cause changes to the shortcut configuration files to become active.

This function will replace the live config files with the temporary
versions constructed by other functions and cause KDE to re-read its
configuration files.
Expand Down
4 changes: 2 additions & 2 deletions wacom-gui/keystroke.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Form implementation generated from reading ui file 'keystroke_dialog.ui'
#
# Created: Wed Oct 24 15:09:24 2018
# by: PyQt4 UI code generator 4.10.1
# by: PyQt5 UI code generator 4.10.1
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtGui

try:
_fromUtf8 = QtCore.QString.fromUtf8
Expand Down
6 changes: 3 additions & 3 deletions wacom-gui/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#!/usr/bin/env python3

from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtGui
import sys
import os
import re
Expand Down Expand Up @@ -146,7 +146,7 @@ def getTabletArea(self):
cmd = "xdpyinfo | grep dimensions | awk '{print $2}' | awk -Fx '{print $1, $2}'"
totalResolution = os.popen(cmd).read()
totalResolution = totalResolution.split()
display = [[0 for x in xrange(3)] for x in xrange(3)]
display = [[0 for x in range(3)] for x in range(3)]
display[2][2] = 1.0
display[0][0] = float(screen.width()) / float(totalResolution[0])
# percent of screen height
Expand Down
23 changes: 12 additions & 11 deletions wacom-gui/pad.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# TODO: mapping to specific


#!/usr/bin/python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSvg import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtSvg import *
from hotkeys import HotkeyWidget
from stylus import WacomAttribSlider
import pad_ui
Expand Down Expand Up @@ -110,7 +111,7 @@ def load_dconf(self):
f.close()
os.popen("dconf load /org/mate/desktop/keybindings/ < %s" % config)
except Exception as e:
print e
print(e)

# This doesn't actually 'load' kde, but merely replicates the logic of the
# load_dconf (MATE) path in the KDE path. This code that ensures
Expand All @@ -123,13 +124,13 @@ def load_kde(self):
if not os.path.isdir(config):
os.mkdir(config)
except Exception as e:
print e
print(e)

def _load_keyboard_shortcuts(self):
custom = {}
p = subprocess.Popen("dconf dump /org/mate/desktop/keybindings/", shell=True, stdout=subprocess.PIPE)
p.wait()
output = p.communicate()[0].split('\n')
output = p.communicate()[0].decode('utf-8').split('\n')
for line in output:
if '[custom' in line:
entry = line[1:-1]
Expand Down Expand Up @@ -159,7 +160,7 @@ def init_keys(self, dev_id, image, buttons, cmds):
but_loc = {}
for bid in sorted(buttons.keys()):
but_loc[bid] = buttons[bid]['pos']
for bid, value in sorted(but_loc.iteritems(), key=lambda (k, v): (v, k)):
for bid, value in sorted(but_loc.items(), key=lambda t: (t[1], t[0])):
if cmds.__len__() == 0:
keystroke = "Default"
else:
Expand Down Expand Up @@ -208,7 +209,7 @@ def init_keys(self, dev_id, image, buttons, cmds):
svg_vspace.changeSize(0, img_h, QSizePolicy.Fixed, QSizePolicy.Fixed)
svg_hspace.changeSize(img_w, hspace, QSizePolicy.Fixed, QSizePolicy.Fixed)
except Exception as e:
print (e)
print(e)
# start to build...
# add top row
if self.buttons['top'].__len__() != 0:
Expand Down Expand Up @@ -354,14 +355,14 @@ def init(self, dev_id, settings):
text = "%s - %s" % (control, data[fingers][control]['text'])
self.guide.addWidget(GuideWidget(data[fingers][control]['icon'], text))
except Exception as e:
print e
print(e)
group = QGroupBox("Touch Controls")
group.setFixedSize(290, 80)
group.setLayout(touch)
gesture = QGroupBox("Gesture Controls List")
gesture.setLayout(self.guide)
gesture.setContentsMargins(6, 6, 6, 6)
self.layout.setMargin(0)
# self.layout.setMargin(0)
self.layout.addWidget(group, 0, 0, 1, 1, Qt.AlignTop)
self.layout.addWidget(gesture, 0, 1, 5, 1, Qt.AlignVCenter)
self.layout.addWidget(self.taptime, 1, 0, 1, 1, Qt.AlignTop)
Expand Down
Loading