Configure WM_NAME and WM_CLASS (as shown in xprop) in PyQt4

How to configure PyQt4 program WM_NAME and WM_CLASS lines as shown in xprop ?

Consider, for example:

 from PyQt4 import QtGui, QtCore import sys if __name__ == '__main__': app = QtGui.QApplication(sys.argv) app.setStyle("plastique") listView = QtGui.QListView() listView.show() combobox = QtGui.QComboBox() combobox.show() sys.exit(app.exec_()) 

If I run this (a file called xprop_test.py ) via python xprop_test.py and call the linux xprop tool for either ListView or ComboBox, it shows

 WM_NAME(STRING) = "xprop_test.py" 

and

 WM_CLASS(STRING) = "xprop_test.py", "Xprop_test.py" 

How to set WM_NAME and WM_CLASS to a different user value (different from the file name)?

How can I install it for the whole program? How to configure it for each individual element of the GUI?

+7
source share
1 answer

The WM_NAME line is just a title bar, which can be set as follows:

 listView.setWindowTitle('listview') 

giving:

 WM_NAME(STRING) = "listView" 

It's hard to affect WM_CLASS . By default, it is created from argv[0] , and there seems to be no way to change this programmatically using the Qt API. However, the first part of the line can be changed by running the program with the -name parameter as follows:

 python xprop_test.py -name FooBar 

giving:

 WM_CLASS(STRING) = "FooBar", "Xprop_test.py" 
+3
source

All Articles