Question

Je voudrais faire un panneau comme application à l'aide PyQt4 pour Linux. Pour cela, je dois la fenêtre i créé:

  • à undecorated
  • d'avoir un espace réservé
  • pour apparaître sur tous les espaces de travail

De la lecture la documentation i ai eu l'idée que je devrais utiliser QtWindowFlags. Mais je n'ai pas la moindre idée quant à la façon de le faire. Aussi je crois qu'il devrait y avoir un endroit indice Qt.WindowType dire la WM la fenêtre est une application « dock ». J'ai fait cela avec pygtk ce fil , mais ici avec Qt i ne pas vraiment savoir comment gérer cela. (J'ai besoin Qt pour sa capacité à thème / application de la peau plus facilement.)

Voici le code actuel je l'ai fait (rien extraordinaire).

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()

aide quelqu'un peut me avec cela? Merci:)

Était-ce utile?

La solution 3

La solution consiste à utiliser Python-Xlib, et il a été décrit dans une réponse sur une manière universelle à l'espace de l'écran de réserve sur X .

Autres conseils

Lire sur la propriété QWidget.windowFlags: http://doc.qt.nokia.com /4.7/qwidget.html#windowFlags-prop

Exemple:

>>> from PyQt4 import QtGui, QtCore
>>> app = QtGui.QApplication([])
>>> win = QtGui.QMainWindow()
>>> win.setWindowFlags(win.windowFlags() | QtCore.Qt.FramelessWindowHint)
>>> win.show()
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()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top