NAME and WM

How can I customize the strings WM_NAME and WM_CLASS of a PyQt4 program as shown by 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 (the file is called xprop_test.py ) via python xprop_test.py and invoke the linux tool xprop either for the ListView Or for the ComboBox, it shows

WM_NAME(STRING) = "xprop_test.py"

and

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

How can I set the strings WM_NAME and WM_CLASS to another custom value (different from the filename)?

How can I set it for the whole program? How can I adjust it for each individual GUI element?


The WM_NAME string is simply the title-bar caption, which can be set like this:

listView.setWindowTitle('listview')

giving:

WM_NAME(STRING) = "listView"

The WM_CLASS is harder to affect. By default, it's constructed from argv[0] , and there does not appear to be a way to change this programmatically using the Qt APIs. However, the first part of the string can be changed by running the program with a -name option like this:

python xprop_test.py -name FooBar

giving:

WM_CLASS(STRING) = "FooBar", "Xprop_test.py"
链接地址: http://www.djcxy.com/p/11064.html

上一篇: 如何正确包含用python拟合的不确定性

下一篇: NAME和WM