Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PySide2 import QtWidgets,QtCore,QtGui
- class myWindow(QtWidgets.QDialog):
- def __init__(self, parent=None):
- super(myWindow, self).__init__(parent)
- self.actionHello = QtWidgets.QAction("Hello",self)
- #self.actionHello.setText("Hola")
- self.actionHello.triggered.connect(self.PrintHello)
- self.actionBye = QtWidgets.QAction("Bye",self)
- #self.actionBye.setText("Bye")
- self.actionBye.triggered.connect(self.PrintBye)
- self.actionMeh = QtWidgets.QAction("Meh",self)
- #self.actionMeh.setText("Meh")
- self.actionMeh.triggered.connect(self.PrintMeh)
- self.menu = QtWidgets.QMenu(self)
- self.menu.addAction(self.actionHello)
- self.menu.addAction(self.actionBye)
- self.menu.addSeparator()
- self.menu.addAction(self.actionMeh)
- self.buttonShow = QtWidgets.QPushButton(self)
- self.buttonShow.setText("Cool Menu")
- self.buttonShow.setMenu(self.menu)
- self.layout = QtWidgets.QVBoxLayout(self)
- self.layout.addWidget(self.buttonShow)
- self.show()
- def PrintHello(self):
- print "Hello"
- def PrintBye(self):
- print "Bye"
- def PrintMeh(self):
- print "Meh"
- win=myWindow()
Advertisement
Add Comment
Please, Sign In to add comment