Advertisement
programusy

23234sdsdss

Feb 26th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import sys
  2.  
  3. from PyQt5.QtWidgets import *
  4. from PyQt5.QtCore import *
  5. from PyQt5.QtGui import *
  6.  
  7. from PyQt5 import *
  8.  
  9.  
  10. class Window(QMainWindow):
  11. def __init__(self):
  12. super().__init__()
  13.  
  14. self.init_ui()
  15.  
  16. def init_ui(self):
  17. font = "Verdana"
  18. self.setWindowTitle('Licznik blokow')
  19. self.setGeometry(100, 100, 800, 600)
  20.  
  21. self.label = QLabel(self)
  22. self.canvas = QPixmap(600, 600)
  23. self.canvas.fill(QColor(Qt.lightGray))
  24. self.label.setPixmap(self.canvas)
  25. self.setCentralWidget(self.label)
  26.  
  27. self.btn1 = QPushButton("GORA", self)
  28. self.btn1.setGeometry(620, 40, 150, 50)
  29. self.btn1.clicked.connect(self.gora)
  30.  
  31. self.btn2 = QPushButton("DOL", self)
  32. self.btn2.setGeometry(620, 510, 150, 50)
  33. self.btn2.clicked.connect(self.dol)
  34.  
  35.  
  36. self.show()
  37.  
  38. def gora(self):
  39. print("gora")
  40. painter = QPainter(self.label.pixmap())
  41. painter.setPen(QPen(Qt.black, 3, Qt.SolidLine))
  42. painter.fillRect(0,0,600,600, QColor(Qt.lightGray))
  43.  
  44. painter.drawLine(300, 200, 300, 400)
  45. painter.drawLine(300, 250, 200, 200)
  46. painter.drawLine(300, 250, 400, 200)
  47. painter.end()
  48. self.update()
  49.  
  50. def dol(self):
  51. print("dol")
  52.  
  53. if __name__ == '__main__':
  54. app = QApplication(sys.argv)
  55. window = Window()
  56. window.show()
  57. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement