Advertisement
Klokova_Sofi

Andrey_PyQT5_ToolButton_draft

Dec 8th, 2021
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. from PyQt5.QtWidgets import *
  6. #QApplication, QWidget, QToolButton
  7. from PyQt5.QtGui import QIcon
  8.  
  9. class PlusButton(QToolButton):
  10.  
  11. def __init__(self, QWidget):
  12. super().__init__()
  13. self.show()
  14. #self.initUI()
  15. """
  16. def initUI(self):
  17. self.icon = QIcon("C://Users/kloko/Pictures/plus.png")
  18. #self.setPopupMode(self, InstantPopup)
  19. #self.popupMode = QtWidgets.QToolButton.InstantPopup
  20. self.letsMakeMenu()
  21. self.show()
  22.  
  23. def letsMakeMenu(self):
  24. menu = QMenu(self)
  25. menu.addAction(QIcon("C://Users/kloko/Pictures/insert.png"), "Insert multiple rows")
  26. menu.addSeparator()
  27. menu.addAction("Place new rows above selected row")
  28. menu.addAction("Place new rows bellow selected row")
  29. menu.addAction("Place new rows at the end of the data view")
  30. self.setMenu(menu)
  31. """
  32. class Example(QWidget):
  33.  
  34. def __init__(self):
  35. super().__init__()
  36. #self.addButton = PlusButton()
  37. button = PlusButton(self)
  38. button.move(100, 70)
  39. self.initUI()
  40.  
  41. def initUI(self):
  42. self.setGeometry(300, 300, 300, 220)
  43. self.show()
  44.  
  45.  
  46.  
  47. if __name__ == '__main__':
  48. app = QApplication(sys.argv)
  49. ex = Example()
  50. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement