This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5 import QtGui, QtWidgets | |
| if __name__ == "__main__": | |
| app = QtWidgets.QApplication(sys.argv) | |
| view = QtWidgets.QGraphicsView() | |
| scene = QtWidgets.QGraphicsScene() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5 import QtWidgets, QtCore | |
| class CustomTimer(QtCore.QThread): | |
| countDownUpdated = QtCore.pyqtSignal(int) # whenever the countdown changes this signal get emitted | |
| def __init__(self, count_down, sleep=1000, *args, **kwargs): | |
| super(CustomTimer, self).__init__(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5 import QtWidgets, QtCore, QtGui | |
| class ClickableLabel(QtWidgets.QLabel): | |
| # you will have to specify how many arguments and the type of the argument(eg: bool, int, str), in | |
| # our case we will use QPoint to pass mouse position. | |
| # All your signals must be class level, not object level/instance level. | |
| clicked = QtCore.pyqtSignal(QtCore.QPoint) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5 import QtWidgets, QtGui, QtCore | |
| class CustomLabel(QtWidgets.QLabel): | |
| def __init__(self, *args, **kwargs): | |
| super(CustomLabel, self).__init__(*args, **kwargs) | |
| self.start_point = QtCore.QPoint(0, 0) # This is x, y point, we will use Qpoint to represent it | |
| self.end_point = QtCore.QPoint(0, 0) # The QPoint will only take two integers, QPointF for floating point |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| from PyQt5 import QtWidgets, QtGui | |
| class SampleWidget(QtWidgets.QWidget): | |
| def __init__(self, *args, **kwargs): | |
| super(SampleWidget, self).__init__(*args, **kwargs) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout | |
| def change_button_text(): | |
| button.setText("Button has been clicked") | |
| if __name__ == '__main__': | |
| app = QApplication(sys.argv) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout | |
| _style = """ | |
| QWidget{ | |
| background-color: #f5fbff; | |
| } | |
| QLabel{ | |
| color: black; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5.QtWidgets import QApplication, QLabel | |
| from PyQt5.QtGui import QFont, QPalette, QColor | |
| if __name__ == '__main__': | |
| app = QApplication(sys.argv) | |
| label = QLabel("hello") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout | |
| def change_button_text(): | |
| button.setText("Button has been clicked") | |
| if __name__ == '__main__': | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout | |
| def change_button_text(): | |
| button.setText("Button has been clicked") | |
| if __name__ == '__main__': | |