Advertisement
shh_algo_PY

Task 1 - Smart Notes

Dec 3rd, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.53 KB | None | 0 0
  1. from PyQt5.QtCore import Qt
  2.  
  3. from PyQt5.QtWidgets import (
  4.     QApplication, QWidget, QPushButton,
  5.     QLabel, QListWidget, QLineEdit,
  6.     QTextEdit, QInputDialog, QHBoxLayout,
  7.     QVBoxLayout, QFormLayout)
  8.  
  9. import json
  10.  
  11. app = QApplication([])
  12.  
  13. '''Application interface'''
  14. # Application window parameters
  15. notes_win = QWidget()
  16. notes_win.setWindowTitle('Smart Notes')
  17. notes_win.resize(900, 600)
  18.  
  19. # Application window widgets
  20. # List widget: List of notes [New this week!]
  21. list_notes = QListWidget()
  22. list_notes_label = QLabel('List of notes')
  23.  
  24. # Buttons under the list of notes
  25. button_note_create = QPushButton('Create note')
  26. button_note_del = QPushButton('Delete note')
  27. button_note_save = QPushButton('Save note')
  28.  
  29. # Creates a field to insert tags [New this week!]
  30. field_tag = QLineEdit('') # Creates a blank field
  31. field_tag.setPlaceholderText('Enter tag...') # Text prompt inside the field
  32. field_text = QTextEdit() # Field for entering text
  33.  
  34. # Buttons for all the tags
  35. button_add = QPushButton('Add to note')
  36. button_del = QPushButton('Untag from note')
  37. button_search = QPushButton('Search notes by tag')
  38.  
  39. # List widget: List of tags
  40. list_tags = QListWidget()
  41. list_tags_label = QLabel('List of tags')
  42.  
  43. # Arranging widgets by layout
  44. layout_notes = QHBoxLayout()
  45. col_1 = QVBoxLayout()
  46. col_1.addWidget(field_text) # This is where you type the note!
  47.  
  48. col_2 = QVBoxLayout()
  49. col_2.addWidget(list_notes_label)   # Label - List of notes
  50. col_2.addWidget(list_notes)         # List of notes
  51.  
  52. row_1 = QHBoxLayout()
  53. row_1.addWidget(button_note_create) # Create and delete buttons in Row 1
  54. row_1.addWidget(button_note_del)
  55.  
  56. row_2 = QHBoxLayout()
  57. row_2.addWidget(button_note_save)   # Save button in Row 2
  58. col_2.addLayout(row_1)              # Add Row 1 and Row 2 onto Col 2
  59. col_2.addLayout(row_2)
  60.  
  61. # In column 2, we also have the tags!
  62. col_2.addWidget(list_tags_label)    # Label - tags
  63. col_2.addWidget(list_tags)          # List of tags
  64. col_2.addWidget(field_tag)          # Key in tags
  65.  
  66. row_3 = QHBoxLayout()               # Column 2 has two more rows
  67. row_3.addWidget(button_add)         # Row 3 - add, delete buttons
  68. row_3.addWidget(button_del)
  69. row_4 = QHBoxLayout()
  70. row_4.addWidget(button_search)      # Row 4 - Search
  71.  
  72. col_2.addLayout(row_3)              # Add Row 3 and 4 onto Col 2
  73. col_2.addLayout(row_4)
  74.  
  75. layout_notes.addLayout(col_1, stretch = 2)      # STRETCHING FACTOR
  76. layout_notes.addLayout(col_2, stretch = 1)  
  77. notes_win.setLayout(layout_notes)
  78.  
  79. # Run the application
  80. notes_win.show()
  81. app.exec_()
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement