PyQt4: how to make an undercorated window with reserved space

I would like to make a panel-like application using PyQt4 for Linux. for this I need the window that I created:

  • to be unecorated
  • reserved space
  • appears on all workspaces

From reading the documentation , I got the idea that I should use QtWindowFlags. But I do not know how to do this. I also think that Qt.WindowType should be a hint, telling the dock application somewhere in the WM window. I did this with pygtk after this thread , but here with Qt I really don't know how to handle this. (I need Qt for its ability to apply theme / skin more easily.)

Below is the current code I made (nothing unusual).

import sys from PyQt4 import QtGui class Panel(QtGui.QWidget): def __init__(self, parent=None): ## should the QtWindowFlag be here? QtGui.QWidget.__init__(self, parent) ## should the QtWindowFlag be there as well? self.setWindowTitle('QtPanel') self.resize(QtGui.QDesktopWidget().screenGeometry().width(), 25) self.move(0,0) def main(): app = QtGui.QApplication(sys.argv) panel = Panel() panel.show() sys.exit(app.exec_()) return 0 if __name__ == '__main__': main() 

Can anyone help me with this? Thanks:)

0
source share
3 answers

The solution is to use Python-Xlib, and it was described in response to a universal way to reserve screen space in X.

0
source

Read more about the properties of QWidget.windowFlags: http://doc.qt.nokia.com/4.7/qwidget.html#windowFlags-prop

Example:

 >>> from PyQt4 import QtGui, QtCore >>> app = QtGui.QApplication([]) >>> win = QtGui.QMainWindow() >>> win.setWindowFlags(win.windowFlags() | QtCore.Qt.FramelessWindowHint) >>> win.show() 
+6
source
 import sys from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): qbtn = QtGui.QPushButton('Quit', self) #qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit) qbtn.clicked.connect(self.test) qbtn.resize(qbtn.sizeHint()) qbtn.move(50, 50) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Quit button') self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) self.show() def test(self): print "test" def main(): app = QtGui.QApplication(sys.argv) ex = Example() sys.exit(app.exec_()) if __name__ == '__main__': main() 
+1
source

All Articles