-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
64 lines (51 loc) · 1.28 KB
/
app.py
File metadata and controls
64 lines (51 loc) · 1.28 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import random
import string
import sys
from PySide6.QtWidgets import (
QApplication,
QLabel,
QLineEdit,
QPushButton,
QVBoxLayout,
QWidget,
)
from PySide6.QtCore import Qt
c = string.digits + string.ascii_letters
x = ''.join(random.choices(c, k=5))
app = QApplication(sys.argv)
window = QWidget()
window.resize(400, 400)
layout = QVBoxLayout()
input_string = QLineEdit()
input_string.setPlaceholderText("Type here the code...")
title = QLabel("Complete the catpcha")
code = QLabel(x)
label = QLabel("...")
btn = QPushButton("Set")
btn2 = QPushButton("Volver a generar")
label.setAlignment(Qt.AlignCenter)
code.setAlignment(Qt.AlignCenter)
title.setAlignment(Qt.AlignCenter)
input_string.setAlignment(Qt.AlignCenter)
def random_code():
global x
x = ''.join(random.choices(c, k=5))
code.setText(x)
label.setText("...") # limpia el resultado
def generate_code():
a = input_string.text()
if a == x:
label.setText("Correct")
else:
label.setText("Wrong!, try again")
btn.clicked.connect(generate_code)
btn2.clicked.connect(random_code)
layout.addWidget(title)
layout.addWidget(code)
layout.addWidget(input_string)
layout.addWidget(btn)
layout.addWidget(btn2)
layout.addWidget(label)
window.setLayout(layout)
window.show()
app.exec()