├── LICENSE ├── README.chinese.md ├── README.hindi.md ├── README.md ├── README.ru.md ├── alive.py ├── images ├── Notepad.gif ├── clean.png ├── copy.png ├── cut.png ├── file_open.png ├── file_open1.png ├── file_print.png ├── file_print1.png ├── file_save.png ├── file_save1.png ├── file_saveas.png ├── file_saveas1.png ├── notepad.png ├── paste.png ├── redo.png ├── selectall.png ├── undo.png └── wrap.png ├── main.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Andrej Marinchenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.chinese.md: -------------------------------------------------------------------------------- 1 | # NotePad 2 | Your own notebook written in python. 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 | 17 | 18 | Read in other languages: [English](README.md), [हिन्दी](README.hindi.md), [Russian](README.ru.md) 19 | 20 | 21 | 22 | ![GUI](images/Notepad.gif) 23 | 24 | 25 | ##如何安裝和運行 26 | ____ 27 | ### 克隆存儲庫 28 | 29 | ```sh 30 | $ cmd 31 | $ git clone https://github.com/BEPb/NotePad 32 | $ cd NotePad 33 | ``` 34 | 35 | ### 安裝必要的包(安裝依賴) 36 | ```sh 37 | $ pip install -r requirements.txt 38 | 39 | ``` 40 | 41 | ## 用法 42 | 要啟動 GUI: 43 | ``` 44 | python3 -m main 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /README.hindi.md: -------------------------------------------------------------------------------- 1 | # NotePad 2 | पायथन में लिखी आपकी अपनी नोटबुक। 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 | 17 | 18 | Read in other languages: [English](README.md), [Russian](README.ru.md), [中國人](README.chinese.md) 19 | 20 | 21 | 22 | ![GUI](images/Notepad.gif) 23 | 24 | 25 | ## कैसे स्थापित करें और चलाएं 26 | ____ 27 | ### रिपॉजिटरी को क्लोन करें 28 | 29 | ```sh 30 | $ cmd 31 | $ git clone https://github.com/BEPb/NotePad 32 | $ cd NotePad 33 | ``` 34 | 35 | ### आवश्यक पैकेज स्थापित करें (निर्भरता स्थापित करें) 36 | ```sh 37 | $ pip install -r requirements.txt 38 | 39 | ``` 40 | 41 | ## उपयोग 42 | 要啟動 GUI: 43 | ``` 44 | python3 -m main 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NotePad 2 | Your own notebook written in python. 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 | 17 | 18 | 19 | Read in other languages: [Russian](README.ru.md), [हिन्दी](README.hindi.md), [中國人](README.chinese.md) 20 | 21 | 22 | 23 | ![GUI](images/Notepad.gif) 24 | 25 | 26 | 27 | ## How to install and run 28 | ____ 29 | ### Clone the repository 30 | 31 | ```sh 32 | $ cmd 33 | $ git clone https://github.com/BEPb/NotePad 34 | $ cd NotePad 35 | ``` 36 | 37 | ### Install the necessary packages (Install dependencies) 38 | ```sh 39 | $ pip install -r requirements.txt 40 | 41 | ``` 42 | 43 | ## Usage 44 | To launch the GUI: 45 | ``` 46 | python3 -m main 47 | ``` 48 | 49 | -------------------------------------------------------------------------------- /README.ru.md: -------------------------------------------------------------------------------- 1 | # NotePad 2 | Свой собственный блокнот написанный на питоне. 3 |

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

15 | 16 | 17 | 18 | Читать на других языках: [English](README.md), [हिन्दी](README.hindi.md), [中國人](README.chinese.md) 19 | 20 | 21 | 22 | ![GUI](images/Notepad.gif) 23 | 24 | 25 | ## Порядок установки и запуска 26 | ____ 27 | ### Клонируем репозиторий (Clone the repository) 28 | 29 | ```sh 30 | $ cmd 31 | $ git clone https://github.com/BEPb/NotePad 32 | $ cd NotePad 33 | ``` 34 | 35 | ### Устанавливаем необходимые пакеты (Install dependencies) 36 | ```sh 37 | $ pip install -r requirements.txt 38 | 39 | ``` 40 | 41 | ## Использование 42 | Чтобы запустить графический интерфейс: 43 | ``` 44 | python main.py 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /alive.py: -------------------------------------------------------------------------------- 1 | import pyautogui 2 | import time 3 | pyautogui.FAILSAFE=False 4 | while True: 5 | time.sleep(15) 6 | for i in range(100): 7 | pyautogui.moveTo(0,i*5) 8 | for i in range(3): 9 | pyautogui.press('shift') -------------------------------------------------------------------------------- /images/Notepad.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/Notepad.gif -------------------------------------------------------------------------------- /images/clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/clean.png -------------------------------------------------------------------------------- /images/copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/copy.png -------------------------------------------------------------------------------- /images/cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/cut.png -------------------------------------------------------------------------------- /images/file_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_open.png -------------------------------------------------------------------------------- /images/file_open1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_open1.png -------------------------------------------------------------------------------- /images/file_print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_print.png -------------------------------------------------------------------------------- /images/file_print1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_print1.png -------------------------------------------------------------------------------- /images/file_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_save.png -------------------------------------------------------------------------------- /images/file_save1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_save1.png -------------------------------------------------------------------------------- /images/file_saveas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_saveas.png -------------------------------------------------------------------------------- /images/file_saveas1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/file_saveas1.png -------------------------------------------------------------------------------- /images/notepad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/notepad.png -------------------------------------------------------------------------------- /images/paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/paste.png -------------------------------------------------------------------------------- /images/redo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/redo.png -------------------------------------------------------------------------------- /images/selectall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/selectall.png -------------------------------------------------------------------------------- /images/undo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/undo.png -------------------------------------------------------------------------------- /images/wrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BEPb/NotePad/e642f32eba7f2f92471297ad6c9034f5706260f0/images/wrap.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python 3.9 программа консоли блокнота (текстовый редактор) 3 | Название файла main.py 4 | 5 | Version: 0.1 6 | Author: Andrej Marinchenko 7 | Date: 2022-04-16 8 | """ 9 | import sys, os 10 | from PyQt5.QtWidgets import ( 11 | QApplication, 12 | QMainWindow, 13 | QWidget, 14 | QAction, 15 | QPlainTextEdit, 16 | QToolBar, 17 | QVBoxLayout, 18 | QFileDialog, 19 | QMessageBox, 20 | ) 21 | from PyQt5.QtCore import Qt, QSize 22 | from PyQt5.QtGui import QFontDatabase, QIcon, QKeySequence 23 | from PyQt5.QtPrintSupport import QPrintDialog 24 | 25 | 26 | class Notepad(QMainWindow): 27 | def __init__(self) -> None: 28 | super().__init__() 29 | self.setWindowTitle("Notepad 2.0") 30 | self.screen_width, self.screen_height = ( 31 | self.geometry().width(), 32 | self.geometry().height(), 33 | ) 34 | self.resize(self.screen_width, self.screen_height) 35 | self.setWindowIcon(QIcon("images/notepad.png")) 36 | self.show() 37 | 38 | self.filterTypes = "Text Document (*.txt);; Python (*.py);; Markdown (*.md)" 39 | self.path = None 40 | 41 | fixedFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) 42 | fixedFont.setPointSize(12) 43 | mainlayout = QVBoxLayout() 44 | 45 | # Editor 46 | self.editor = QPlainTextEdit() 47 | self.editor.setFont(fixedFont) 48 | mainlayout.addWidget(self.editor) 49 | 50 | # statusBar 51 | self.statusBar = self.statusBar() 52 | 53 | # app container 54 | container = QWidget() 55 | container.setLayout(mainlayout) 56 | self.setCentralWidget(container) 57 | 58 | # File menus 59 | filemenu = self.menuBar().addMenu("&File") 60 | 61 | # Edit menu 62 | editmenu = self.menuBar().addMenu('&Edit') 63 | # file Toolbar 64 | file_toolbar = QToolBar() 65 | file_toolbar.setIconSize(QSize(30, 30)) 66 | self.addToolBar(Qt.BottomToolBarArea, file_toolbar) 67 | self.update_title() 68 | 69 | # Edit Toolbar 70 | edit_toolbar = QToolBar() 71 | edit_toolbar.setIconSize(QSize(30, 30)) 72 | self.addToolBar(Qt.BottomToolBarArea, edit_toolbar) 73 | 74 | """ 75 | Undo, Redo actions 76 | """ 77 | undo_action = self.create_action( 78 | self, 79 | 'images/undo.png', 80 | 'Undo', 81 | 'Undo', 82 | QKeySequence.Undo, 83 | self.editor.undo 84 | ) 85 | redo_action = self.create_action( 86 | self, 87 | 'images/redo.png', 88 | 'Redo', 89 | 'Redo', 90 | QKeySequence.Redo, 91 | self.editor.redo 92 | ) 93 | # clear action 94 | clear = self.create_action( 95 | self, 96 | 'images/clean.png', 97 | 'Clear', 98 | 'Clear', 99 | 'ctrl+shift+c', 100 | self.editor.clear 101 | ) 102 | editmenu.addActions([undo_action, redo_action, clear]) 103 | edit_toolbar.addActions([undo_action,redo_action, clear]) 104 | 105 | # cut, copy, paste, select all 106 | cut_action=self.create_action( 107 | self, 108 | 'images/cut.png', 109 | 'Cut', 110 | 'Cut', 111 | QKeySequence.Cut, 112 | self.editor.cut 113 | ) 114 | copy_action=self.create_action( 115 | self, 116 | 'images/copy.png', 117 | 'Copy', 118 | 'Copy', 119 | QKeySequence.Copy, 120 | self.editor.copy 121 | ) 122 | paste_action=self.create_action( 123 | self, 124 | 'images/paste.png', 125 | 'Paste', 126 | 'Paste', 127 | QKeySequence.Paste, 128 | self.editor.paste 129 | ) 130 | select_action=self.create_action( 131 | self, 132 | 'images/selectall.png', 133 | 'Select All', 134 | 'Select All', 135 | QKeySequence.SelectAll, 136 | self.editor.selectAll 137 | ) 138 | # Wrap text action 139 | wrap_action=self.create_action( 140 | self, 141 | 'images/wrap.png', 142 | 'Wrap Text', 143 | 'Wrap Text', 144 | 'ctrl+shift+W', 145 | lambda : self.editor.setLineWrapMode(not self.editor.lineWrapMode()) 146 | ) 147 | edit_toolbar.addActions([cut_action,copy_action,paste_action,select_action, wrap_action]) 148 | editmenu.addActions([cut_action,copy_action,paste_action,select_action, wrap_action]) 149 | 150 | 151 | """ 152 | open, save, saveAs 153 | """ 154 | file_open = self.create_action( 155 | self, 156 | "images/file_open1.png", 157 | "Open File", 158 | "Open File", 159 | QKeySequence.Open, 160 | self.file_open, 161 | ) 162 | file_save = self.create_action( 163 | self, 164 | "images/file_save1.png", 165 | "Save", 166 | "Save File", 167 | QKeySequence.Save, 168 | self.file_save, 169 | ) 170 | file_saveas = self.create_action( 171 | self, 172 | "images/file_saveas1.png", 173 | "Save As", 174 | "Save As", 175 | QKeySequence.SaveAs, 176 | self.file_saveas, 177 | ) 178 | file_print = self.create_action( 179 | self, 180 | "images/file_print1.png", 181 | "Print File", 182 | "Print File", 183 | QKeySequence.Print, 184 | self.file_print, 185 | ) 186 | filemenu.addActions([file_open, file_save, file_saveas, file_print]) 187 | file_toolbar.addActions([file_open, file_save, file_saveas, file_print]) 188 | def file_save(self): 189 | if self.path is None: 190 | self.file_saveas() 191 | else: 192 | try: 193 | text= self.editor.toPlainText() 194 | with open(self.path,'w') as f: 195 | f.write(text) 196 | self.dialog_message(f'File saved succesfully at {self.path}', QMessageBox.Information) 197 | except Exception as e: 198 | self.dialog_message(e, QMessageBox.Critical) 199 | else: 200 | pass 201 | def file_saveas(self): 202 | path, _ = QFileDialog.getSaveFileName( 203 | self, 204 | 'Save File', 205 | '', 206 | self.filterTypes 207 | ) 208 | text= self.editor.toPlainText() 209 | try: 210 | with open(path,'w') as f: 211 | f.write(text) 212 | self.dialog_message(f'File saved succesfully at {path}', QMessageBox.Information) 213 | except Exception as e: 214 | self.dialog_message(e, QMessageBox.Critical) 215 | else: 216 | self.path=path 217 | self.update_title() 218 | 219 | 220 | def file_open(self): 221 | path,_=QFileDialog.getOpenFileName( 222 | self, 223 | caption='Open File', 224 | directory='', 225 | filter=self.filterTypes 226 | ) 227 | if path: 228 | try: 229 | with open(path, 'r') as f: 230 | text=f.read() 231 | except Exception as e: 232 | self.dialog_message(str(e)) 233 | else: 234 | self.path= path 235 | self.editor.setPlainText(text) 236 | self.update_title() 237 | self.editor.update() 238 | def file_print(self): 239 | printDlg= QPrintDialog() 240 | if printDlg.exec_(): 241 | self.editor.print(printDlg.printer()) 242 | pass 243 | def update_title(self): 244 | self.setWindowTitle('{} - Notepad 2.0'.format(os.path.basename(self.path) if self.path is not None else 'Unititled')) 245 | 246 | def dialog_message(self, message,type): 247 | dlg = QMessageBox(self) 248 | dlg.setText(message) 249 | dlg.setIcon(type) 250 | dlg.show() 251 | 252 | def create_action( 253 | self, parent, icon, action_name, status_tip, shortcut, triggered_method 254 | ): 255 | action = QAction(QIcon(icon), action_name, parent) 256 | action.setStatusTip(status_tip) 257 | action.triggered.connect(triggered_method) 258 | action.setShortcut(shortcut) 259 | return action 260 | 261 | def save_file(self): 262 | pass 263 | 264 | 265 | app = QApplication(sys.argv) 266 | notepad = Notepad() 267 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyQt5==5.15.3 2 | PyQt5-Qt==5.15.2 3 | PyQt5-sip==12.8.1 4 | --------------------------------------------------------------------------------