sheetah-gui 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.3
2
+ Name: sheetah-gui
3
+ Version: 0.1.1
4
+ Summary: Add your description here
5
+ Author: Carsten Engelke
6
+ Author-email: Carsten Engelke <carsten.engelke@gmail.com>
7
+ Requires-Dist: nicegui>=3.9.0
8
+ Requires-Dist: pywebview>=6.1
9
+ Requires-Dist: sheetah>=0.2.1
10
+ Requires-Python: >=3.13
11
+ Description-Content-Type: text/markdown
12
+
File without changes
@@ -0,0 +1,21 @@
1
+ [project]
2
+ name = "sheetah-gui"
3
+ version = "0.1.1"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Carsten Engelke", email = "carsten.engelke@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.13"
10
+ dependencies = [
11
+ "nicegui>=3.9.0",
12
+ "pywebview>=6.1",
13
+ "sheetah>=0.2.1",
14
+ ]
15
+
16
+ [project.scripts]
17
+ sheetah-gui = "sheetah_gui:main"
18
+
19
+ [build-system]
20
+ requires = ["uv_build>=0.10.2,<0.11.0"]
21
+ build-backend = "uv_build"
@@ -0,0 +1,19 @@
1
+ """Package entrypoint for :mod:`sheetah-gui`.
2
+
3
+ The top-level ``main`` function is simply routed to the command‑line
4
+ implementation so installing the package and invoking ``sheetah-gui`` will
5
+ launch the interactive search UI. Helper classes are re-exported here as a
6
+ convenience for programmatic use.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from sheetah import Document, Segment
12
+ from . import gui
13
+
14
+ __all__ = ["Document", "Segment", "gui", "main"]
15
+
16
+
17
+ def main() -> None:
18
+ """Run the graphical interface."""
19
+ gui.main()
@@ -0,0 +1,97 @@
1
+ """Graphical interface for searching documents created from Markdown."""
2
+
3
+ from __future__ import annotations
4
+ import sys
5
+ from pathlib import Path
6
+ from nicegui import app, events, native, ui
7
+ from sheetah.sheetah import Document, Segment
8
+
9
+ class DocSearchUI():
10
+ def __init__(self, document: Document):
11
+ self.document = document
12
+ self.results: list[Segment] = document.items
13
+ self.page = ui.page(path="/", title="sheetah")
14
+ self.openfiledialog = ui.dialog().classes('w-1/2')
15
+ with ui.header():
16
+ with ui.row(wrap=False, align_items='stretch').classes('w-full'):
17
+ with ui.button(icon='menu'):
18
+ with ui.menu() as menu:
19
+ ui.menu_item("Open File", self.openfiledialog.open)
20
+ ui.menu_item("Save File", self._download_document)
21
+ ui.menu_item("Clear List", self._clear_list)
22
+ self.search_field = ui.input(label='Search', on_change=self._on_search_change, placeholder='Type to search...').classes('w-full')
23
+ self.result_area = ui.column().classes('w-full').style('overflow-y: auto; padding: 10px; gap: 10px')
24
+ with ui.footer():
25
+ self.status_bar = ui.label("Ready.").classes('w-full text-left')
26
+ with self.openfiledialog:
27
+ with ui.card():
28
+ ui.label("Upload a Markdown file to append to the current document.").classes('text-center')
29
+ ui.upload(label="Choose File", on_upload=self._handle_file_upload).props('accept=.md').classes('w-full')
30
+ ui.button("Close", on_click=lambda: self.openfiledialog.close()).classes('w-full')
31
+ self._update_results()
32
+
33
+ def _on_search_change(self, event):
34
+ text = event.value
35
+ self.results = self.document.search(text)
36
+ self._update_results()
37
+
38
+ def _update_results(self):
39
+ self.result_area.clear()
40
+ for element in self.results:
41
+ with self.result_area.classes('h-100%'):
42
+ with ui.card().classes('w-full'):
43
+ ui.label(element.name).style('font-size: 130%; font-weight: bold')
44
+ ui.markdown(element.markdown()).classes('whitespace-pre-wrap')
45
+ ui.button(icon='content_copy', on_click=lambda e, t=element.text(): self._copy_current(e, t)).classes('absolute bottom-2 right-2')
46
+
47
+ def _copy_current(self, event, copytext: str):
48
+ if self.results:
49
+ ui.clipboard.write(copytext) # copy the specified text
50
+ self.status_bar.text = "Copied to clipboard!"
51
+
52
+ async def _handle_file_upload(self, event: events.UploadEventArguments, append=False):
53
+ file = event.file
54
+ text = await file.text()
55
+ other = Document.from_markdown(text)
56
+ for seg in other.items:
57
+ self.document.append(seg.name, seg._markdown)
58
+ self.results = self.document.items
59
+ self.search_field.value = "" # clear search field to show all results
60
+ self._update_results()
61
+ self.status_bar.text = f"File '{file.name}' uploaded and added to Document."
62
+ self.openfiledialog.close()
63
+
64
+ def _download_document(self):
65
+ markdown_content = self.document.to_markdown()
66
+ ui.download.content(markdown_content, filename="sheetah_document.md")
67
+ self.status_bar.text = "Document downloaded as 'sheetah_document.md'."
68
+
69
+ def _clear_list(self):
70
+ self.document.items.clear()
71
+ self.results.clear()
72
+ self._update_results()
73
+ self.status_bar.text = "Document cleared."
74
+
75
+ doc = Document(items=[], description="sheetah + " + str(Path.cwd()))
76
+ for file in Path.cwd().glob("*.md"):
77
+ text = open(file, encoding="utf-8").read()
78
+ # append segments from subsequent files to the same document
79
+ other = Document.from_markdown(text)
80
+ for seg in other.items:
81
+ doc.append(seg.name, seg._markdown)
82
+ searchUI = DocSearchUI(doc)
83
+
84
+
85
+ def main() -> None:
86
+ """Start the NiceGUI application."""
87
+ ui.run(
88
+ searchUI.page,
89
+ title="sheetah",
90
+ favicon="https://i.ibb.co/tPCktPtz/sheetah256.png",
91
+ reload=False,
92
+ )
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
97
+
@@ -0,0 +1,38 @@
1
+ # -*- mode: python ; coding: utf-8 -*-
2
+
3
+
4
+ a = Analysis(
5
+ ['gui.py'],
6
+ pathex=[],
7
+ binaries=[],
8
+ datas=[('C:\\Users\\Carsten\\Projects\\sheetah-gui\\.venv\\Lib\\site-packages\\nicegui', 'nicegui')],
9
+ hiddenimports=[],
10
+ hookspath=[],
11
+ hooksconfig={},
12
+ runtime_hooks=[],
13
+ excludes=[],
14
+ noarchive=False,
15
+ optimize=0,
16
+ )
17
+ pyz = PYZ(a.pure)
18
+
19
+ exe = EXE(
20
+ pyz,
21
+ a.scripts,
22
+ a.binaries,
23
+ a.datas,
24
+ [],
25
+ name='sheetah',
26
+ debug=False,
27
+ bootloader_ignore_signals=False,
28
+ strip=False,
29
+ upx=True,
30
+ upx_exclude=[],
31
+ runtime_tmpdir=None,
32
+ console=True,
33
+ disable_windowed_traceback=False,
34
+ argv_emulation=False,
35
+ target_arch=None,
36
+ codesign_identity=None,
37
+ entitlements_file=None,
38
+ )
@@ -0,0 +1,17 @@
1
+ from nicegui import ui
2
+
3
+ def on_search(e):
4
+ resultarea.clear()
5
+ for i in range(10):
6
+ with resultarea.classes('h-100%'):
7
+ with ui.card().classes('w-full'):
8
+ ui.label(f"Result {i+1}").style('font-size: 130%; font-weight: bold')
9
+ ui.label("Lorem ipsum dolor sit amet, consectetur adipiscing elit. alkdlskdas asdasdakl daslk dalksd aslkd aslkd aslkd aslkd alskd laskd alsk dlaskd laskd alsk dalksd alkd alsk dalsk dalskd alskd ").style('font-size: 90%')
10
+ ui.button(icon='content_copy', on_click=lambda: ui.notify("Copied to clipboard!")).classes('absolute bottom-2 right-2')
11
+
12
+ ui.page(path="/", title="sheetah",)
13
+ with ui.header():
14
+ ui.input(label='Search', on_change=on_search, placeholder='Type to search...').classes('w-full')
15
+ resultarea = ui.column().classes('w-full').style('overflow-y: auto; padding: 10px; gap: 10px')
16
+
17
+ ui.run(native=True, window_size=(800, 600), fullscreen=False, title="sheetah", favicon="https://drive.google.com/file/d/1MxEEg6wsrJ84uhoyJj_ti-ekqIwFw2EV/view?usp=sharing", )