Skip to content

Instantly share code, notes, and snippets.

@RicardoViana
Last active December 13, 2017 11:33
Show Gist options
  • Select an option

  • Save RicardoViana/5300561 to your computer and use it in GitHub Desktop.

Select an option

Save RicardoViana/5300561 to your computer and use it in GitHub Desktop.
wacom xubuntu stylus buttons configuration tool
import sys
from PyQt4 import QtGui, QtCore
import os
import subprocess
class Wacom(QtGui.QWidget):
def __init__(self):
super(Wacom, self).__init__()
self.initUI()
def initUI(self):
self.setFixedSize(265,250)
self.setWindowTitle("Wacom")
#layouts
leftLayout=QtGui.QVBoxLayout()
rightLayout=QtGui.QVBoxLayout()
#widgets
rightWidget=QtGui.QWidget(parent=self)
rightWidget.setGeometry(5,5,250,200)
rightWidget.setLayout(rightLayout)
#optionlists
buttonsList=["-","LMB","MMB","RMB"]
#buttons
getDeviceCmd="xsetwacom --list devices | grep STYLUS"
self.getDevice=subprocess.Popen(getDeviceCmd,stdout=subprocess.PIPE,shell=True)
self.device=self.getDevice.stdout.readline().split("id")[0].strip()
self.deviceLabel=QtGui.QLabel(self.device)
self.topLabel=QtGui.QLabel("Upper Button")
self.topButton=QtGui.QComboBox()
self.topButton.addItems(buttonsList)
self.lowLabel=QtGui.QLabel("Lower Button")
self.bottomButton=QtGui.QComboBox()
self.bottomButton.addItems(buttonsList)
setButton=QtGui.QPushButton("Apply")
setButton.clicked.connect(self.setup)
rightLayout.addWidget(self.deviceLabel)
rightLayout.addWidget(self.topLabel)
rightLayout.addWidget(self.topButton)
rightLayout.addWidget(self.lowLabel)
rightLayout.addWidget(self.bottomButton)
rightLayout.addWidget(setButton)
self.show()
def setup(self):
topValue=self.topButton.currentIndex()
bottomValue=self.bottomButton.currentIndex()
os.system("xsetwacom set '%s' button 3 %d" %(self.device,topValue))
os.system("xsetwacom set '%s' button 2 %d" %(self.device,bottomValue))
def main():
app = QtGui.QApplication(sys.argv)
app.setStyle("Plastique")
ex = Wacom()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment