Last active
December 13, 2017 11:33
-
-
Save RicardoViana/5300561 to your computer and use it in GitHub Desktop.
wacom xubuntu stylus buttons configuration tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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