Guest User

Untitled

a guest
Oct 16th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.27 KB | None | 0 0
  1. from PySide2 import QtWidgets,QtCore,QtGui
  2.  
  3.  
  4. class myWindow(QtWidgets.QDialog):
  5.     def __init__(self, parent=None):
  6.         super(myWindow, self).__init__(parent)
  7.         self.actionHello = QtWidgets.QAction("Hello",self)
  8.         #self.actionHello.setText("Hola")
  9.         self.actionHello.triggered.connect(self.PrintHello)
  10.  
  11.         self.actionBye = QtWidgets.QAction("Bye",self)
  12.         #self.actionBye.setText("Bye")
  13.         self.actionBye.triggered.connect(self.PrintBye)
  14.  
  15.         self.actionMeh = QtWidgets.QAction("Meh",self)
  16.         #self.actionMeh.setText("Meh")
  17.         self.actionMeh.triggered.connect(self.PrintMeh)
  18.  
  19.  
  20.         self.menu = QtWidgets.QMenu(self)
  21.         self.menu.addAction(self.actionHello)
  22.         self.menu.addAction(self.actionBye)
  23.         self.menu.addSeparator()
  24.         self.menu.addAction(self.actionMeh)
  25.  
  26.         self.buttonShow = QtWidgets.QPushButton(self)
  27.         self.buttonShow.setText("Cool Menu")
  28.         self.buttonShow.setMenu(self.menu)
  29.  
  30.         self.layout = QtWidgets.QVBoxLayout(self)
  31.         self.layout.addWidget(self.buttonShow)
  32.         self.show()
  33.  
  34.     def PrintHello(self):
  35.         print "Hello"
  36.  
  37.     def PrintBye(self):
  38.         print "Bye"
  39.  
  40.     def PrintMeh(self):
  41.         print "Meh"
  42.  
  43. win=myWindow()
Advertisement
Add Comment
Please, Sign In to add comment