Advertisement
Guest User

Untitled

a guest
Jul 13th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. from PySide import QtCore, QtGui
  2.  
  3. class TestWidget(QtGui.QWidget):
  4.   """
  5.  A simple Pie menu class. Use in a similar way to QMenu: Create a PieMenu and add QActions to it with QAction.
  6.  """
  7.  
  8.   def __init__(self, parent=None):
  9.     super(TestWidget, self).__init__(parent)
  10.  
  11.     # with this flag set the application does not quit properly, without it does
  12.     self.setWindowFlags(QtCore.Qt.Popup)
  13.  
  14.   def mousePressEvent(self, e):
  15.     self.close()
  16.  
  17.   def keyPressEvent(self, event):
  18.     if event.key() == QtCore.Qt.Key_Escape:
  19.       self.close()
  20.  
  21.  
  22. if __name__ == '__main__':
  23.   import sys
  24.   app = QtGui.QApplication(sys.argv)
  25.   w = TestWidget()
  26.   w.show()
  27.   sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement