Advertisement
programusy

123ssss

Feb 26th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 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(100, 100, 150, 200)
  45. painter.end()
  46. self.update()
  47.  
  48. def dol(self):
  49. print("dol")
  50.  
  51. if __name__ == '__main__':
  52. app = QApplication(sys.argv)
  53. window = Window()
  54. window.show()
  55. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement