-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyQt5_blink_ButtonPressed.py
More file actions
41 lines (38 loc) · 1.12 KB
/
PyQt5_blink_ButtonPressed.py
File metadata and controls
41 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from PyQt5.QtWidgets import QWidget,QApplication,QLabel,QPushButton
from PyQt5.QtGui import QPixmap
import sys
class app(QWidget):
a = 1
def __init__(self):
super().__init__()
self.titulo = "UMAKER"
self.x = 300
self.y = 300
self.w = 600
self.h = 300
self.init_UI()
def init_UI(self):
self.setWindowTitle(self.titulo)
self.setGeometry(self.x,self.y,self.w,self.h)
self.verde = QPixmap("led_verde.png")
self.azul = QPixmap("led_azul.png")
#creamos un texto
self.label1 = QLabel(self)
boton = QPushButton("click!",self)
boton.move(150,150)
self.label1.setPixmap(self.azul)
self.label1.move(20,20)
boton.clicked.connect(self.on_click)
self.show()
def on_click(self):
self.a=self.a+1
print("se presiono")
if self.a%2==0:
self.label1.setPixmap(self.verde)
self.label1.move(20,20)
else:
self.label1.setPixmap(self.azul)
self.label1.move(20,20)
aux = QApplication([])
ex = app()
sys.exit(aux.exec_())