-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
113 lines (90 loc) · 3.77 KB
/
main.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
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
import sys
import os
print(os.getcwd())
os.chdir(os.getcwd())
stylesheet = os.path.abspath('css/stylesheet.css')
sys.path.append("resources")
ciphers = ['Cezar', 'Supstitucija', 'Vigenere', 'Playfair','Hill', 'Transpozicija', 'Jednokratna bilj.', 'DES kriptosustav']
from PyQt5.QtWidgets import (QWidget,QMainWindow, QLineEdit, QLabel, QCheckBox, QHBoxLayout, QVBoxLayout, QGridLayout,QPushButton, QApplication, QFrame, QMainWindow)
from PyQt5 import QtGui
from PyQt5.QtCore import Qt
from caesar_gui import caesarFrame
from supstitutionFrame import supstitutionFrame
from vigenereFrame import vigenereFrame
from playfairFrame import playfairFrame
from transpositionFrame import transpositionFrame
from onetimepadFrame import onetimepadFrame
from hillFrame import hillFrame
from desFrame import desFrame
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.alphabet = 'abcdefghijklmnopqrstuvwxyz'
self.grid_layout = QGridLayout()
self.setWindowTitle('CryptoSys')
self.buttons = []
self.initUI()
self.centralWidget = QWidget()
self.centralWidget.setLayout(self.grid_layout)
self.setCentralWidget(self.centralWidget)
self.setStyleSheet(open(stylesheet).read())
self.setFixedWidth(600)
#konfiguracija korisnickog sucelja
def initUI(self):
self.frame = caesarFrame()
self.frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
self.v_box = QVBoxLayout()
logo = QLabel(self)
pixmap = QtGui.QPixmap(os.path.abspath('images/logo.png'))
logo.setPixmap(pixmap)
self.v_box.addWidget(logo)
for x in range(8):
self.button = QPushButton(ciphers[x])
self.buttons.append(self.button)
self.button.clicked.connect(lambda: self.buttonClicked())
self.v_box.addWidget(self.button)
self.grid_layout.addLayout(self.v_box, 0, 0, 1, 1)
self.grid_layout.addWidget(self.frame, 0, 1, -1, -1)
self.grid_layout.setColumnStretch(0, 1)
self.grid_layout.setColumnStretch(1, 12)
self.grid_layout.setRowStretch(1, 12)
def updateFrame(self, frame):
self.grid_layout.removeWidget(self.frame)
self.frame.setParent(None)
self.frame = frame
self.frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
self.grid_layout.addWidget(self.frame, 0, 1, -1, -1)
#handler event za odabire gumba koji mijenjaju trenutni frame
def buttonClicked(self):
self.button = self.sender()
if(self.button.text() == 'Cezar'):
frame = caesarFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Supstitucija'):
frame = supstitutionFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Vigenere'):
frame = vigenereFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Playfair'):
frame = playfairFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Hill'):
frame = hillFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Transpozicija'):
frame = transpositionFrame()
self.updateFrame(frame)
elif(self.button.text() == 'Jednokratna bilj.'):
frame = onetimepadFrame()
self.updateFrame(frame)
elif(self.button.text() == 'DES kriptosustav'):
frame = desFrame()
self.updateFrame(frame)
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setWindowIcon(QtGui.QIcon(os.path.abspath('images/icon.png')))
#app.setWindowIcon(QtGui.QIcon('://icon.png'))
window = MainWindow()
window.show()
sys.exit(app.exec_())