-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHost.py
More file actions
140 lines (115 loc) · 4.62 KB
/
Host.py
File metadata and controls
140 lines (115 loc) · 4.62 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic
from PyQt5 import QtCore
from PyQt5 import QtCore, QtGui, QtWidgets
form_thirdwindow = uic.loadUiType("Host.ui")[0]
door_password = input("초기 패스워드(4자리) : ")
password =""
while len(door_password) != 4 : # check password
print("비밀번호는 4자리만 입력하여주시기 바랍니다.")
door_password = ("초기 패스워드 재입력(4자리) : ")
door_password = input("초기 패스워드(4자리) : ")
class Host(QDialog,QWidget,form_thirdwindow):
def __init__(self):
super(Host,self).__init__()
self.initUI()
self.show()
def initUI(self):
self.setupUi(self)
#버튼에 대한 정의
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.btn1.setText(_translate("MainWindow", "1"))
self.btn2.setText(_translate("MainWindow", "2"))
self.btn3.setText(_translate("MainWindow", "3"))
self.btn6.setText(_translate("MainWindow", "6"))
self.btn4.setText(_translate("MainWindow", "4"))
self.btn5.setText(_translate("MainWindow", "5"))
self.btn9.setText(_translate("MainWindow", "9"))
self.btn7.setText(_translate("MainWindow", "7"))
self.btn8.setText(_translate("MainWindow", "8"))
self.cancel.setText(_translate("MainWindow", "취소"))
self.confirm.setText(_translate("MainWindow", "확인"))
self.btn0.setText(_translate("MainWindow", "0"))
self.textlabel.setText(_translate("MainWindow", "Host"))
self.btnBack2.setText(_translate("MainWindow", "Back"))
# 버튼 액션 추가
self.btn1.clicked.connect(self.action1)
self.btn2.clicked.connect(self.action2)
self.btn3.clicked.connect(self.action3)
self.btn4.clicked.connect(self.action4)
self.btn5.clicked.connect(self.action5)
self.btn6.clicked.connect(self.action6)
self.btn7.clicked.connect(self.action7)
self.btn8.clicked.connect(self.action8)
self.btn9.clicked.connect(self.action9)
self.btn0.clicked.connect(self.action0)
self.cancel.clicked.connect(self.action_cancel)
self.confirm.clicked.connect(self.action_confirm)
self.btnBack2.clicked.connect(self.back_to_main)
#각 버튼들에 대한 정의
def action0(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "0")
def action1(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "1")
def action2(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "2")
def action3(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "3")
def action4(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "4")
def action5(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "5")
def action6(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "6")
def action7(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "7")
def action8(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "8")
def action9(self):
# appending label text
text = self.MainWindow_2.text()
self.MainWindow_2.setText(text + "9")
def action_cancel(self):
# clearing the label text
self.MainWindow_2.setText("")
def back_to_main(self):
self.close()
def action_confirm(self):
password = self.MainWindow_2.text()
if len(password) == 4 and door_password == password: # if password 5 and matched suc activate
print("Success")
password = ""
self.MainWindow_2.setText("")
elif len(password) == 4 and door_password != password: # if password is not matched fail activate
print("Fail")
password =""
self.MainWindow_2.setText("")
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Host()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())