-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (95 loc) · 3.28 KB
/
Copy pathmain.py
File metadata and controls
101 lines (95 loc) · 3.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
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
#!/usr/bin/python3
# This App Made By Sina Meysami
# Password Generator v1.0
#
#
#
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUi
import qdarktheme
import sys,random,platform,webbrowser
class Window(QMainWindow):
def __init__(self):
super(Window,self).__init__()
qdarktheme.setup_theme("dark")
loadUi("form.ui",self)
self.setWindowTitle("Password Generator")
self.setWindowIcon(QIcon("icon.ico"))
self.setGeometry(600,200,381,560)
self.setFixedSize(381,560)
# Menu
self.save_pass_action.triggered.connect(self.save_password)
self.exit_action.triggered.connect(self.close)
self.spin.setMinimum(6)
self.spin.setMaximum(50)
self.spin.setValue(8)
self.spin.setSingleStep(1)
self.spin.setPrefix("Length: ")
# Buttons
self.generate_btn.clicked.connect(self.generate)
self.ads_btn.clicked.connect(self.ads)
#self.copy_btn.clicked.connect(self.copy_text)
#self.clear_btn.clicked.connect(self.text.clear)
def generate(self):
try:
num = self.spin.value()
PASS = ""
if self.check_line.isChecked() == True:
text = self.line.text()
PASS += text
else:
PASS += ""
if self.check_1.isChecked() == True:
PASS += "ABSCDEFGHIJKLMNOPQRSTUVWXYZ"
else:
PASS += ""
if self.check_2.isChecked() == True:
PASS += "abcdefghijklmnopqrstuvwxyz"
else:
PASS += ""
if self.check_3.isChecked() == True:
PASS += "!@#$%^&*()+"
else:
PASS += ""
if self.check_4.isChecked() == True:
PASS += "1234567890"
else:
PASS += ""
if self.check_5.isChecked() == True:
PASS += "~`[];?,"
else:
PASS += ""
for i in range(num):
n = random.sample(PASS,num)
n2 = "".join(n)
self.text.setText(n2)
except:
mess = QMessageBox(self)
mess.setWindowTitle("Password Generator/Error")
mess.resize(100,50)
mess.setText("Error")
mess.exec_()
def save_password(self):
file_pass = QFileDialog().getSaveFileName(self,"Open File","C:\\","Text Files (*.txt)")
with open(file_pass[0],"w") as file:
file.write(self.text.toPlainText())
def ads(self):
webbrowser.open_new_tab("mailto:sinameysami@gmail.com")
def copy_text(self):
self.text.selectAll()
self.text.copy()
def main():
app = QApplication(sys.argv)
app.setApplicationName("Password Generator")
app.setApplicationVersion("1")
win = Window()
win.show()
sys.exit(app.exec_())
if __name__ == "__main__":
if platform.system() == "Windows" or platform.system() == "Linux" or platform.system() == "Darwin":
main()
else:
print("Please, Run This App On Windows,Linux,Mac OS!")
sys.exit()