Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt5.QtWidgets import *
- from PyQt5.QtCore import *
- from PyQt5.QtGui import *
- from PyQt5 import *
- class Window(QMainWindow):
- def __init__(self):
- super().__init__()
- self.init_ui()
- def init_ui(self):
- font = "Verdana"
- self.setWindowTitle('Licznik blokow')
- self.setGeometry(100, 100, 800, 600)
- self.label = QLabel(self)
- self.canvas = QPixmap(600, 600)
- self.canvas.fill(QColor(Qt.lightGray))
- self.label.setPixmap(self.canvas)
- self.setCentralWidget(self.label)
- self.btn1 = QPushButton("GORA", self)
- self.btn1.setGeometry(620, 40, 150, 50)
- self.btn1.clicked.connect(self.gora)
- self.btn2 = QPushButton("DOL", self)
- self.btn2.setGeometry(620, 510, 150, 50)
- self.btn2.clicked.connect(self.dol)
- self.show()
- def gora(self):
- print("gora")
- painter = QPainter(self.label.pixmap())
- painter.setPen(QPen(Qt.black, 3, Qt.SolidLine))
- painter.fillRect(0,0,600,600, QColor(Qt.lightGray))
- painter.drawLine(300, 200, 300, 400)
- painter.drawLine(300, 250, 200, 200)
- painter.drawLine(300, 250, 400, 200)
- painter.end()
- self.update()
- def dol(self):
- print("dol")
- if __name__ == '__main__':
- app = QApplication(sys.argv)
- window = Window()
- window.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement