This repository has been archived by the owner on Nov 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainform.py
45 lines (33 loc) · 1.79 KB
/
mainform.py
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
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
__author__ = 'ewok'
from PyQt4 import QtCore, QtGui, uic
from utils import generate_password
# прототип главной формы
class MainForm(QtGui.QMainWindow):
# конструктор
def __init__(self):
super(MainForm, self).__init__()
# динамически загружает визуальное представление формы
uic.loadUi("mainform.ui", self)
# связывает событие нажатия на кнопку с методом
self.connect(self.buttonCopy, QtCore.SIGNAL("clicked()"),
self.copyPassToClipboard)
for obj in self.lineMasterPassword, self.lineSalt:
self.connect(obj, QtCore.SIGNAL("textEdited(QString)"), self.update_generated_password)
self.connect(self.spinPasswordLength, QtCore.SIGNAL("valueChanged(int)"), self.update_generated_password)
for obj in self.radioShaSum, self.radioMd5Sum:
self.connect(obj, QtCore.SIGNAL("clicked()"), self.update_generated_password)
def copyPassToClipboard(self):
clipboard = self.app.clipboard()
clipboard.setText(self.plainGeneratedPassword.toPlainText())
def update_generated_password(self):
method = ['sha1sum']
if self.radioShaSum.isChecked():
method = ['sha1sum']
elif self.radioMd5Sum.isChecked():
method = ['md5sum']
self.plainGeneratedPassword.setPlainText(generate_password(self.lineMasterPassword.text(),
self.lineSalt.text(),
method,
self.spinPasswordLength.value()))