-
Notifications
You must be signed in to change notification settings - Fork 28
/
notesWindow.py
104 lines (82 loc) · 3.66 KB
/
notesWindow.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
from PyQt5.QtWidgets import QApplication,QWidget,QLabel,QTextEdit,QVBoxLayout,QGridLayout,QPushButton,QLineEdit,QSizePolicy,QScrollArea,QMessageBox
from PyQt5.QtGui import QIcon,QImage,QPixmap
from PyQt5.QtCore import Qt
import sys
from asset.modules.notesLib.authenticator import createFile,getGrootFolderContent
class noteCreationBox(QWidget):
def __init__(self):
super(noteCreationBox,self).__init__()
self.title = 'Note Maker Google Docs'
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
self.Layout = noteCreationWidgetLayout()
self.setLayout(self.Layout.noteLayout)
self.setGeometry(150,150,800,400)
self.show()
class noteCreationWidgetLayout(QWidget):
def __init__(self,parent=None):
super(noteCreationWidgetLayout,self).__init__()
#Elements Present on Note Creation GUI
self.title = QLabel('Title')
self.titleEdit = QLineEdit()
self.summary = QLabel('Summary')
self.summaryEdit = QTextEdit()
self.saveButton = QPushButton("Save")
self.saveButton.clicked.connect(self.createNewFile)
self.notesList = QPushButton("Notes")
self.notesList.clicked.connect(self.createNotesList)
#Main Layout
self.noteLayout = QGridLayout()
#Position of Widgets/Elements on Main Layout
self.noteLayout.addWidget(self.title, 1, 0)
self.noteLayout.addWidget(self.titleEdit, 1, 1)
self.noteLayout.addWidget(self.summary, 2, 0)
self.noteLayout.addWidget(self.summaryEdit, 2, 1, 10, 1)
self.noteLayout.addWidget(self.saveButton,12,0)
self.noteLayout.addWidget(self.notesList,13,0)
def createNewFile(self):
"""File is created in Groot/ in Google Drive
heading: file with title in the GUI is passed as heading
summary: file content"""
result = createFile(self.titleEdit.text(),self.summaryEdit.toPlainText())
if result == 'Successful':
QMessageBox.about(self, "Successful","File Creation Successful")
else:
QMessageBox.about(self,"Warning",result)
def createNotesList(self):
"Called when note button is clicked.Create scrollable list of notes in new Window"
self.content = getGrootFolderContent()
self.noteWindow = noteShowBox(self.content)
self.noteWindow.show()
class noteShowBox(QWidget):
"""Class to display already created notes in a window"""
def __init__(self,content):
super(noteShowBox,self).__init__()
self.title = 'Created Notes'
self.noteContents = content
self.initUI()
def initUI(self):
self.mainLayout = QVBoxLayout()
self.setWindowTitle(self.title)
self.setGeometry(150,150,800,400)
self.notes = QScrollArea()
self.scroll_widget = QWidget()
self.scroll_layout = QVBoxLayout(self.scroll_widget)
self.scroll_layout.setSpacing(20.0)
#List Generation of all the notes
for key,value in self.noteContents.items():
self.notetile = noteTile(key,value)
self.scroll_layout.addLayout(self.notetile.noteTileLayout)
self.notes.setWidget(self.scroll_widget)
self.mainLayout.addWidget(self.notes)
self.setLayout(self.mainLayout)
self.show()
class noteTile(QWidget):
def __init__(self,heading,summary):
super(noteTile,self).__init__()
self.heading = QLabel('<b>%s</b>'%heading)
self.summary = QLabel(summary)
self.noteTileLayout = QVBoxLayout()
self.noteTileLayout.addWidget(self.heading)
self.noteTileLayout.addWidget(self.summary)