Simple notepad app8/7/2023 ![]() Saveas_file_(self.file_saveas)įile_toolbar.addAction(saveas_file_action) Saveas_file_tStatusTip("Save current page to specified file") Saveas_file_action = QAction(QIcon(os.path.join('images', 'disk-pencil.png')), "Save As.", self) Save_file_tStatusTip("Save current page") Save_file_action = QAction(QIcon(os.path.join('images', 'disk.png')), "Save", self) Open_file_action = QAction(QIcon(os.path.join('images', 'blue-folder-open-document.png')), "Open file.", self) You can use these to enable and disable buttons when they can't be used.įile_menu = nuBar().addMenu("&File") There are also a set of signals available, such as `.copyAvailable` to update the UI when these operations are possible. ![]() The complete list of slots available on a QPlainTextEdit are - Slot Select_action = QAction(QIcon(os.path.join('images', 'selection-input.png')), "Select all", self) Paste_action = QAction(QIcon(os.path.join('images', 'clipboard-paste-document-text.png')), "Paste", self) ![]() Python cut_action = QAction(QIcon(os.path.join('images', 'scissors.png')), "Cut", self)Ĭut_tStatusTip("Cut selected text")Ĭut_()Ĭopy_action = QAction(QIcon(os.path.join('images', 'document-copy.png')), "Copy", self)Ĭopy_tStatusTip("Copy selected text")Ĭopy_() triggered signal from the QAction to the relevant slot enables the behaviour. Below we add a set of toolbar buttons for editing, each defined as a QAction. Triggering any of these operations is simply a case of calling one the slot at the appropriate time. However, the QPlainTextEdit widget actually provides support for all of this through Qt slots. Implementing all these operations on the text buffer directly would take some work. To be useful an editor needs to be able to perform a lot of standard operations - copy, paste, cut, insert, clear. # If none, we haven't got a file open yet (or creating new). # self.path holds the path of the currently open file. # Setup the QTextEdit editor configurationįixedfont = QFontDatabase.systemFont(QFontDatabase.FixedFont) Self.editor = QPlainTextEdit() # Could also use a QTextEdit and set (False) Super(MainWindow, self)._init_(*args, **kwargs)
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |