Simple text editor for basic notes
This commit is contained in:
parent
bd4d571c95
commit
160de4c526
5 changed files with 96 additions and 15 deletions
28
trovedb/qgui/tool_basic_editor.py
Normal file
28
trovedb/qgui/tool_basic_editor.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""Tool Supporting Basic Editor Functions"""
|
||||
from typing import cast, Protocol
|
||||
from PySide6.QtWidgets import QTextEdit, QVBoxLayout
|
||||
|
||||
import trovedb.trove as tr
|
||||
from .tool import Tool
|
||||
|
||||
|
||||
class ToolBasicEditor(Tool):
|
||||
def __init__(self, note, parent=None):
|
||||
super().__init__(note, parent)
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
|
||||
self._text_edit = QTextEdit()
|
||||
layout.addWidget(self._text_edit)
|
||||
self.refresh()
|
||||
|
||||
def _refresh_blob(self, note: tr.Blob):
|
||||
self._text_edit.setPlainText(note.read().decode("utf-8"))
|
||||
|
||||
def refresh(self):
|
||||
if isinstance(self.note, tr.Blob):
|
||||
self._refresh_blob(cast(tr.Blob, self.note))
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue