Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtCore import Qt
- from PyQt5.QtWidgets import (
- QApplication, QWidget, QPushButton,
- QLabel, QListWidget, QLineEdit,
- QTextEdit, QInputDialog, QHBoxLayout,
- QVBoxLayout, QFormLayout)
- import json
- app = QApplication([])
- '''Application interface'''
- # Application window parameters
- notes_win = QWidget()
- notes_win.setWindowTitle('Smart Notes')
- notes_win.resize(900, 600)
- # Application window widgets
- # List widget: List of notes [New this week!]
- list_notes = QListWidget()
- list_notes_label = QLabel('List of notes')
- # Buttons under the list of notes
- button_note_create = QPushButton('Create note')
- button_note_del = QPushButton('Delete note')
- button_note_save = QPushButton('Save note')
- # Creates a field to insert tags [New this week!]
- field_tag = QLineEdit('') # Creates a blank field
- field_tag.setPlaceholderText('Enter tag...') # Text prompt inside the field
- field_text = QTextEdit() # Field for entering text
- # Buttons for all the tags
- button_add = QPushButton('Add to note')
- button_del = QPushButton('Untag from note')
- button_search = QPushButton('Search notes by tag')
- # List widget: List of tags
- list_tags = QListWidget()
- list_tags_label = QLabel('List of tags')
- # Arranging widgets by layout
- layout_notes = QHBoxLayout()
- col_1 = QVBoxLayout()
- col_1.addWidget(field_text) # This is where you type the note!
- col_2 = QVBoxLayout()
- col_2.addWidget(list_notes_label) # Label - List of notes
- col_2.addWidget(list_notes) # List of notes
- row_1 = QHBoxLayout()
- row_1.addWidget(button_note_create) # Create and delete buttons in Row 1
- row_1.addWidget(button_note_del)
- row_2 = QHBoxLayout()
- row_2.addWidget(button_note_save) # Save button in Row 2
- col_2.addLayout(row_1) # Add Row 1 and Row 2 onto Col 2
- col_2.addLayout(row_2)
- # In column 2, we also have the tags!
- col_2.addWidget(list_tags_label) # Label - tags
- col_2.addWidget(list_tags) # List of tags
- col_2.addWidget(field_tag) # Key in tags
- row_3 = QHBoxLayout() # Column 2 has two more rows
- row_3.addWidget(button_add) # Row 3 - add, delete buttons
- row_3.addWidget(button_del)
- row_4 = QHBoxLayout()
- row_4.addWidget(button_search) # Row 4 - Search
- col_2.addLayout(row_3) # Add Row 3 and 4 onto Col 2
- col_2.addLayout(row_4)
- layout_notes.addLayout(col_1, stretch = 2) # STRETCHING FACTOR
- layout_notes.addLayout(col_2, stretch = 1)
- notes_win.setLayout(layout_notes)
- # Run the application
- notes_win.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement