-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainfunctionalitywitherrror
157 lines (118 loc) · 4.34 KB
/
mainfunctionalitywitherrror
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import sys
import os
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QWidget, QAction, QTabWidget,QVBoxLayout,QTextEdit
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
class App(QMainWindow):
def __init__(self):
super().__init__()
self.title = 'CRYPTOPad'
self.left = 0
self.top = 0
self.width = 300
self.height = 200
self.setWindowTitle(self.title)
self.statusBar().showMessage("Welcome to cryptopad")
#open a new file
openAct = QAction(QIcon('food.png'), '&open', self)
openAct.setShortcut('Ctrl+O')
openAct.setStatusTip('open a new file')
#save a new file
saveact=QAction(QIcon("save.png"),"&save",self)
saveact.setShortcut('Ctrl+s')
saveact.setStatusTip("save your file")
#encrypt your file
encryptact=QAction(QIcon("encrypt.png"),"&encrypt",self)
encryptact.setShortcut('Ctrl+e')
encryptact.setStatusTip("encrypt your file")
#decrypt your file
decryptact=QAction(QIcon("decrypt.png"),"&decrypt",self)
decryptact.setShortcut('Ctrl+d')
decryptact.setStatusTip("decrypt your file")
#delete your file
deleteact=QAction(QIcon("delete.png"),'&delete',self)
deleteact.setShortcut("Ctrl+d")
deleteact.setStatusTip("delete your file")
deleteact.triggered.connect(os.remove())
#close your file
closeact=QAction(QIcon('close.png'),"&close",self)
closeact.setShortcut('Ctrl+c')
closeact.setStatusTip('close your file')
closeact.triggered.connect(self.close)
self.statusBar()
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
saveMenu=menubar.addMenu('&save')
encryptMenu=menubar.addMenu('&encrypt')
deleteMenu=menubar.addMenu('&delete')
closemenu=menubar.addMenu('&close')
decryptmenu=menubar.addMenu('&decrypt')
fileMenu.addAction(openAct)
saveMenu.addAction(saveact)
encryptMenu.addAction(encryptact)
deleteMenu.addAction(deleteact)
closemenu.addAction(closeact)
decryptmenu.addAction(decryptact)
#textfield
textEdit = QTextEdit()
self.setCentralWidget(textEdit)
self.setGeometry(self.left, self.top, self.width, self.height)
self.show()
def encrypt(self, parameter_list):
pass
def decrypt(self):
pass
def __quitApplication(self):
self.__root.destroy()
# exit()
def __showAbout(self):
showinfo("Notepad", "Mrinal Verma")
def __openFile(self):
self.__file = askopenfilename(defaultextension=".txt",
filetypes=[("All Files","*.*"),
("Text Documents","*.txt")])
if self.__file == "":
# no file to open
self.__file = None
else:
# try to open the file
# set the window title
self.__root.title(os.path.basename(self.__file) + " - Notepad")
self.__thisTextArea.delete(1.0,END)
file = open(self.__file,"r")
self.__thisTextArea.insert(1.0,file.read())
file.close()
def __newFile(self):
self.__root.title("Untitled - Notepad")
self.__file = None
self.__thisTextArea.delete(1.0,END)
def __saveFile(self):
if self.__file == None:
#save as new file
self.__file = asksaveasfilename(initialfile='Untitled.txt',
defaultextension=".txt",
filetypes=[("All Files","*.*"),
("Text Documents","*.txt")])
if self.__file == "":
self.__file = None
else:
# try to save the file
file = open(self.__file,"w")
file.write(self.__thisTextArea.get(1.0,END))
file.close()
# change the window title
self.__root.title(os.path.basename(self.__file) + " - Notepad")
else:
file = open(self.__file,"w")
file.write(self.__thisTextArea.get(1.0,END))
file.close()
def __cut(self):
self.__thisTextArea.event_generate("<<Cut>>")
def __copy(self):
self.__thisTextArea.event_generate("<<Copy>>")
def __paste(self):
self.__thisTextArea.event_generate("<<Paste>>")
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())