puikit 1.0.0__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.
Files changed (134) hide show
  1. puikit-1.0.0/LICENSE +21 -0
  2. puikit-1.0.0/PKG-INFO +121 -0
  3. puikit-1.0.0/README.md +86 -0
  4. puikit-1.0.0/puikit/__init__.py +72 -0
  5. puikit-1.0.0/puikit/backend.py +706 -0
  6. puikit-1.0.0/puikit/backends/__init__.py +46 -0
  7. puikit-1.0.0/puikit/backends/_d3d_shader.py +540 -0
  8. puikit-1.0.0/puikit/backends/_macos_menu.py +213 -0
  9. puikit-1.0.0/puikit/backends/_metal.py +199 -0
  10. puikit-1.0.0/puikit/backends/_terminal_graphics.py +360 -0
  11. puikit-1.0.0/puikit/backends/_ttf.py +234 -0
  12. puikit-1.0.0/puikit/backends/_web_server.py +223 -0
  13. puikit-1.0.0/puikit/backends/_win32_dragdrop.py +741 -0
  14. puikit-1.0.0/puikit/backends/_win32_ime.py +254 -0
  15. puikit-1.0.0/puikit/backends/_win32_menu.py +122 -0
  16. puikit-1.0.0/puikit/backends/_win32_native.py +1921 -0
  17. puikit-1.0.0/puikit/backends/curses_backend.py +1985 -0
  18. puikit-1.0.0/puikit/backends/macos_backend.py +3188 -0
  19. puikit-1.0.0/puikit/backends/memory_backend.py +415 -0
  20. puikit-1.0.0/puikit/backends/web/client.css +79 -0
  21. puikit-1.0.0/puikit/backends/web/client.js +916 -0
  22. puikit-1.0.0/puikit/backends/web/index.html +13 -0
  23. puikit-1.0.0/puikit/backends/web_backend.py +1075 -0
  24. puikit-1.0.0/puikit/backends/windows_backend.py +2991 -0
  25. puikit-1.0.0/puikit/background.py +246 -0
  26. puikit-1.0.0/puikit/capability.py +155 -0
  27. puikit-1.0.0/puikit/color.py +209 -0
  28. puikit-1.0.0/puikit/easing.py +165 -0
  29. puikit-1.0.0/puikit/event.py +106 -0
  30. puikit-1.0.0/puikit/focus.py +131 -0
  31. puikit-1.0.0/puikit/font.py +92 -0
  32. puikit-1.0.0/puikit/fonts/NotoSans-Bold.ttf +0 -0
  33. puikit-1.0.0/puikit/fonts/NotoSans-Regular.ttf +0 -0
  34. puikit-1.0.0/puikit/fonts/NotoSansCJKjp-Regular.otf +0 -0
  35. puikit-1.0.0/puikit/fonts/NotoSansMono-Bold.ttf +0 -0
  36. puikit-1.0.0/puikit/fonts/NotoSansMono-Regular.ttf +0 -0
  37. puikit-1.0.0/puikit/fonts/NotoSansMonoCJKjp-Regular.otf +0 -0
  38. puikit-1.0.0/puikit/fonts/OFL-CJK.txt +92 -0
  39. puikit-1.0.0/puikit/fonts/OFL.txt +93 -0
  40. puikit-1.0.0/puikit/image.py +158 -0
  41. puikit-1.0.0/puikit/layout.py +491 -0
  42. puikit-1.0.0/puikit/menu.py +96 -0
  43. puikit-1.0.0/puikit/panel.py +2697 -0
  44. puikit-1.0.0/puikit/posteffect.py +129 -0
  45. puikit-1.0.0/puikit/text.py +403 -0
  46. puikit-1.0.0/puikit/textfx.py +403 -0
  47. puikit-1.0.0/puikit/theme.py +337 -0
  48. puikit-1.0.0/puikit/widgets/__init__.py +65 -0
  49. puikit-1.0.0/puikit/widgets/_input.py +84 -0
  50. puikit-1.0.0/puikit/widgets/_selection.py +250 -0
  51. puikit-1.0.0/puikit/widgets/base.py +139 -0
  52. puikit-1.0.0/puikit/widgets/busy_indicator.py +116 -0
  53. puikit-1.0.0/puikit/widgets/button.py +293 -0
  54. puikit-1.0.0/puikit/widgets/checkbox.py +114 -0
  55. puikit-1.0.0/puikit/widgets/combo_box.py +307 -0
  56. puikit-1.0.0/puikit/widgets/container.py +105 -0
  57. puikit-1.0.0/puikit/widgets/dragbar.py +129 -0
  58. puikit-1.0.0/puikit/widgets/drawer.py +354 -0
  59. puikit-1.0.0/puikit/widgets/dropdown.py +265 -0
  60. puikit-1.0.0/puikit/widgets/image.py +93 -0
  61. puikit-1.0.0/puikit/widgets/json_view.py +571 -0
  62. puikit-1.0.0/puikit/widgets/label.py +80 -0
  63. puikit-1.0.0/puikit/widgets/layout_view.py +113 -0
  64. puikit-1.0.0/puikit/widgets/list.py +337 -0
  65. puikit-1.0.0/puikit/widgets/log_view.py +756 -0
  66. puikit-1.0.0/puikit/widgets/markdown_view.py +2197 -0
  67. puikit-1.0.0/puikit/widgets/menu.py +389 -0
  68. puikit-1.0.0/puikit/widgets/message_box.py +358 -0
  69. puikit-1.0.0/puikit/widgets/progress_bar.py +91 -0
  70. puikit-1.0.0/puikit/widgets/radio.py +181 -0
  71. puikit-1.0.0/puikit/widgets/scroll_bar.py +30 -0
  72. puikit-1.0.0/puikit/widgets/scroll_view.py +210 -0
  73. puikit-1.0.0/puikit/widgets/splitter.py +344 -0
  74. puikit-1.0.0/puikit/widgets/table_view.py +618 -0
  75. puikit-1.0.0/puikit/widgets/tabs.py +252 -0
  76. puikit-1.0.0/puikit/widgets/text_block.py +107 -0
  77. puikit-1.0.0/puikit/widgets/text_edit.py +643 -0
  78. puikit-1.0.0/puikit/widgets/tree.py +283 -0
  79. puikit-1.0.0/puikit.egg-info/PKG-INFO +121 -0
  80. puikit-1.0.0/puikit.egg-info/SOURCES.txt +132 -0
  81. puikit-1.0.0/puikit.egg-info/dependency_links.txt +1 -0
  82. puikit-1.0.0/puikit.egg-info/requires.txt +16 -0
  83. puikit-1.0.0/puikit.egg-info/top_level.txt +1 -0
  84. puikit-1.0.0/pyproject.toml +68 -0
  85. puikit-1.0.0/setup.cfg +4 -0
  86. puikit-1.0.0/tests/test_alpha.py +172 -0
  87. puikit-1.0.0/tests/test_auto_ink.py +103 -0
  88. puikit-1.0.0/tests/test_background.py +240 -0
  89. puikit-1.0.0/tests/test_background_idle.py +292 -0
  90. puikit-1.0.0/tests/test_capability.py +40 -0
  91. puikit-1.0.0/tests/test_cjk_fonts.py +272 -0
  92. puikit-1.0.0/tests/test_clipboard_rich.py +41 -0
  93. puikit-1.0.0/tests/test_color.py +138 -0
  94. puikit-1.0.0/tests/test_container.py +158 -0
  95. puikit-1.0.0/tests/test_corner_brackets.py +147 -0
  96. puikit-1.0.0/tests/test_curses_colors.py +225 -0
  97. puikit-1.0.0/tests/test_curses_emoji.py +140 -0
  98. puikit-1.0.0/tests/test_curses_input.py +433 -0
  99. puikit-1.0.0/tests/test_curses_wide_glyph.py +130 -0
  100. puikit-1.0.0/tests/test_d3d_shader.py +174 -0
  101. puikit-1.0.0/tests/test_drawer.py +278 -0
  102. puikit-1.0.0/tests/test_easing.py +151 -0
  103. puikit-1.0.0/tests/test_focus.py +272 -0
  104. puikit-1.0.0/tests/test_font.py +96 -0
  105. puikit-1.0.0/tests/test_image_widgets.py +315 -0
  106. puikit-1.0.0/tests/test_input_widgets.py +1124 -0
  107. puikit-1.0.0/tests/test_json_view.py +171 -0
  108. puikit-1.0.0/tests/test_label_padding.py +51 -0
  109. puikit-1.0.0/tests/test_layout.py +418 -0
  110. puikit-1.0.0/tests/test_log_view.py +308 -0
  111. puikit-1.0.0/tests/test_macos_backend.py +586 -0
  112. puikit-1.0.0/tests/test_markdown_view.py +1159 -0
  113. puikit-1.0.0/tests/test_menu.py +231 -0
  114. puikit-1.0.0/tests/test_message_box.py +103 -0
  115. puikit-1.0.0/tests/test_more_widgets.py +460 -0
  116. puikit-1.0.0/tests/test_panel.py +947 -0
  117. puikit-1.0.0/tests/test_posteffect.py +356 -0
  118. puikit-1.0.0/tests/test_reduced_motion.py +128 -0
  119. puikit-1.0.0/tests/test_shader_background.py +255 -0
  120. puikit-1.0.0/tests/test_table_view.py +287 -0
  121. puikit-1.0.0/tests/test_tabs.py +115 -0
  122. puikit-1.0.0/tests/test_terminal_graphics.py +562 -0
  123. puikit-1.0.0/tests/test_text.py +268 -0
  124. puikit-1.0.0/tests/test_text_input_gating.py +124 -0
  125. puikit-1.0.0/tests/test_textfx.py +984 -0
  126. puikit-1.0.0/tests/test_theme.py +97 -0
  127. puikit-1.0.0/tests/test_theme_recipes.py +56 -0
  128. puikit-1.0.0/tests/test_tree.py +99 -0
  129. puikit-1.0.0/tests/test_vector_widgets.py +194 -0
  130. puikit-1.0.0/tests/test_web_backend.py +525 -0
  131. puikit-1.0.0/tests/test_widgets.py +372 -0
  132. puikit-1.0.0/tests/test_win32_dragdrop.py +89 -0
  133. puikit-1.0.0/tests/test_windows_backend.py +1005 -0
  134. puikit-1.0.0/tests/test_windows_background.py +162 -0
puikit-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 craftware
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.
puikit-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: puikit
3
+ Version: 1.0.0
4
+ Summary: Capability-based Python UI framework with TUI and GUI backends
5
+ Author: craftware
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/crftwr/puikit
8
+ Project-URL: Repository, https://github.com/crftwr/puikit
9
+ Project-URL: Issues, https://github.com/crftwr/puikit/issues
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: User Interfaces
19
+ Classifier: Topic :: Terminals
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.21
24
+ Requires-Dist: windows-curses>=2.4; sys_platform == "win32"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8; extra == "dev"
27
+ Requires-Dist: pytest-timeout>=2; extra == "dev"
28
+ Requires-Dist: pillow>=9; extra == "dev"
29
+ Provides-Extra: macos
30
+ Requires-Dist: pyobjc-framework-Cocoa>=10; extra == "macos"
31
+ Requires-Dist: pyobjc-framework-Quartz>=10; extra == "macos"
32
+ Provides-Extra: images
33
+ Requires-Dist: pillow>=9; extra == "images"
34
+ Dynamic: license-file
35
+
36
+ # PuiKit
37
+
38
+ PuiKit is a capability-based Python UI framework that supports both TUI
39
+ (terminal) and GUI (desktop, web) backends. Build apps and widgets once, run
40
+ them on multiple backends without splitting implementations.
41
+
42
+ - Apps and widgets specify **what to draw (intent)**
43
+ - **How to draw (implementation)** is decided by the backend
44
+ - Backends declare their capabilities; the Panel layer resolves fallbacks
45
+ - Widget code never branches on TUI/GUI
46
+
47
+ See the [documentation](https://github.com/crftwr/puikit/tree/main/docs) for
48
+ design notes and per-system guides (layout, rendering, color, animation, fonts,
49
+ widgets, and more).
50
+
51
+ ## Status
52
+
53
+ Stable release (1.0). Implemented:
54
+
55
+ - Core framework: `Panel`, `Backend` interface, capability profiles, event model
56
+ - Layout system: `HSplit` / `VSplit` / `Item` with weights and `min_px` / `min`
57
+ hints — snapped to whole base units on TUI, resolved at pixel granularity on GUI
58
+ - Animation: `panel.animate(widget, hints={"transition": "fade", "duration_ms": 200})`
59
+ — transitions `fade` (opacity), `slide` (position), `scale` (visual zoom),
60
+ `size` (layout reflow), and `highlight` (color) rendered on the macOS
61
+ backend; immediate switch on TUI
62
+ - Widgets: `Label`, `ListView`, `ScrollBar`, `Container`
63
+ - Widget tree: containers nest widgets with hierarchical clipping; animations
64
+ on a parent cascade to all descendants, while children stay individually
65
+ animatable
66
+ - Backends:
67
+ - `CursesBackend` — TUI, all platforms
68
+ - `MacOSBackend` — macOS native GUI (PyObjC; install with `pip install -e ".[macos]"`)
69
+ - `WindowsBackend` — Windows native GUI (raw ctypes; Direct2D/DirectWrite)
70
+ - `WebBackend` — runs in a web browser, launched with `webbrowser` over a
71
+ local WebSocket (`--backend web`; see `docs/web_backend.md`)
72
+ - `MemoryBackend` — headless, for tests
73
+ - Planned next: C++ CoreText render extension
74
+
75
+ ## Quick start
76
+
77
+ ```bash
78
+ python3.14 -m venv .venv
79
+ .venv/bin/pip install -e ".[dev]"
80
+
81
+ # Run the examples (in a terminal)
82
+ .venv/bin/python examples/hello_world/main.py
83
+ .venv/bin/python examples/demo_catalog/main.py
84
+
85
+ # On macOS, the same examples in a native window
86
+ .venv/bin/python examples/hello_world/main.py --backend gui
87
+ .venv/bin/python examples/demo_catalog/main.py --backend gui
88
+
89
+ # Or in a web browser (opens a tab; works on any platform)
90
+ .venv/bin/python examples/demo_catalog/main.py --backend web
91
+
92
+ # Run the tests
93
+ .venv/bin/python -m pytest
94
+ ```
95
+
96
+ ## Minimal app
97
+
98
+ ```python
99
+ from puikit import EventType, Panel
100
+ from puikit.backends import create_backend
101
+ from puikit.widgets import Label
102
+
103
+ backend = create_backend("tui")
104
+ with backend:
105
+ panel = Panel(backend)
106
+ panel.add(Label("Hello, PuiKit!"), x=2, y=1, w=30, h=1)
107
+ panel.render()
108
+
109
+ def on_event(event):
110
+ if event.type is EventType.KEY and event.key == "q":
111
+ backend.quit()
112
+ return
113
+ panel.dispatch_event(event)
114
+ panel.render()
115
+
116
+ backend.run_event_loop(on_event)
117
+ ```
118
+
119
+ ## License
120
+
121
+ See [LICENSE](https://github.com/crftwr/puikit/blob/main/LICENSE).
puikit-1.0.0/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # PuiKit
2
+
3
+ PuiKit is a capability-based Python UI framework that supports both TUI
4
+ (terminal) and GUI (desktop, web) backends. Build apps and widgets once, run
5
+ them on multiple backends without splitting implementations.
6
+
7
+ - Apps and widgets specify **what to draw (intent)**
8
+ - **How to draw (implementation)** is decided by the backend
9
+ - Backends declare their capabilities; the Panel layer resolves fallbacks
10
+ - Widget code never branches on TUI/GUI
11
+
12
+ See the [documentation](https://github.com/crftwr/puikit/tree/main/docs) for
13
+ design notes and per-system guides (layout, rendering, color, animation, fonts,
14
+ widgets, and more).
15
+
16
+ ## Status
17
+
18
+ Stable release (1.0). Implemented:
19
+
20
+ - Core framework: `Panel`, `Backend` interface, capability profiles, event model
21
+ - Layout system: `HSplit` / `VSplit` / `Item` with weights and `min_px` / `min`
22
+ hints — snapped to whole base units on TUI, resolved at pixel granularity on GUI
23
+ - Animation: `panel.animate(widget, hints={"transition": "fade", "duration_ms": 200})`
24
+ — transitions `fade` (opacity), `slide` (position), `scale` (visual zoom),
25
+ `size` (layout reflow), and `highlight` (color) rendered on the macOS
26
+ backend; immediate switch on TUI
27
+ - Widgets: `Label`, `ListView`, `ScrollBar`, `Container`
28
+ - Widget tree: containers nest widgets with hierarchical clipping; animations
29
+ on a parent cascade to all descendants, while children stay individually
30
+ animatable
31
+ - Backends:
32
+ - `CursesBackend` — TUI, all platforms
33
+ - `MacOSBackend` — macOS native GUI (PyObjC; install with `pip install -e ".[macos]"`)
34
+ - `WindowsBackend` — Windows native GUI (raw ctypes; Direct2D/DirectWrite)
35
+ - `WebBackend` — runs in a web browser, launched with `webbrowser` over a
36
+ local WebSocket (`--backend web`; see `docs/web_backend.md`)
37
+ - `MemoryBackend` — headless, for tests
38
+ - Planned next: C++ CoreText render extension
39
+
40
+ ## Quick start
41
+
42
+ ```bash
43
+ python3.14 -m venv .venv
44
+ .venv/bin/pip install -e ".[dev]"
45
+
46
+ # Run the examples (in a terminal)
47
+ .venv/bin/python examples/hello_world/main.py
48
+ .venv/bin/python examples/demo_catalog/main.py
49
+
50
+ # On macOS, the same examples in a native window
51
+ .venv/bin/python examples/hello_world/main.py --backend gui
52
+ .venv/bin/python examples/demo_catalog/main.py --backend gui
53
+
54
+ # Or in a web browser (opens a tab; works on any platform)
55
+ .venv/bin/python examples/demo_catalog/main.py --backend web
56
+
57
+ # Run the tests
58
+ .venv/bin/python -m pytest
59
+ ```
60
+
61
+ ## Minimal app
62
+
63
+ ```python
64
+ from puikit import EventType, Panel
65
+ from puikit.backends import create_backend
66
+ from puikit.widgets import Label
67
+
68
+ backend = create_backend("tui")
69
+ with backend:
70
+ panel = Panel(backend)
71
+ panel.add(Label("Hello, PuiKit!"), x=2, y=1, w=30, h=1)
72
+ panel.render()
73
+
74
+ def on_event(event):
75
+ if event.type is EventType.KEY and event.key == "q":
76
+ backend.quit()
77
+ return
78
+ panel.dispatch_event(event)
79
+ panel.render()
80
+
81
+ backend.run_event_loop(on_event)
82
+ ```
83
+
84
+ ## License
85
+
86
+ See [LICENSE](https://github.com/crftwr/puikit/blob/main/LICENSE).
@@ -0,0 +1,72 @@
1
+ """PuiKit — a capability-based Python UI framework for TUI and GUI."""
2
+
3
+ from .backend import (
4
+ Backend,
5
+ CapabilityNotSupported,
6
+ DEFAULT_STYLE,
7
+ Style,
8
+ TextAttribute,
9
+ )
10
+ from .capability import (
11
+ CapabilityProfile,
12
+ PROFILE_GAME,
13
+ PROFILE_GUI_DESKTOP,
14
+ PROFILE_GUI_WEB,
15
+ PROFILE_MOBILE,
16
+ PROFILE_TUI,
17
+ )
18
+ from .easing import EASINGS, Easing, resolve as resolve_easing
19
+ from .event import Event, EventType
20
+ from .font import Font, FontSlant, FontWeight
21
+ from .background import Shader, Wallpaper
22
+ from .layout import HSplit, Item, VSplit
23
+ from .menu import SEPARATOR, Menu, MenuItem, MenuSeparator
24
+ from .panel import DrawContext, Panel, Rect
25
+ from .posteffect import CRT, PRESETS, PostEffect
26
+ from .theme import THEME_GUI, THEME_TUI, Theme, derive_theme, lift, mix, theme_for
27
+
28
+ __version__ = "1.0.0"
29
+
30
+ __all__ = [
31
+ "Backend",
32
+ "Shader",
33
+ "Wallpaper",
34
+ "CapabilityNotSupported",
35
+ "CapabilityProfile",
36
+ "DEFAULT_STYLE",
37
+ "DrawContext",
38
+ "EASINGS",
39
+ "Easing",
40
+ "Event",
41
+ "EventType",
42
+ "Font",
43
+ "FontSlant",
44
+ "FontWeight",
45
+ "HSplit",
46
+ "Item",
47
+ "Menu",
48
+ "MenuItem",
49
+ "MenuSeparator",
50
+ "Panel",
51
+ "PostEffect",
52
+ "CRT",
53
+ "PRESETS",
54
+ "PROFILE_GAME",
55
+ "PROFILE_GUI_DESKTOP",
56
+ "PROFILE_GUI_WEB",
57
+ "PROFILE_MOBILE",
58
+ "PROFILE_TUI",
59
+ "Rect",
60
+ "SEPARATOR",
61
+ "Style",
62
+ "TextAttribute",
63
+ "THEME_GUI",
64
+ "THEME_TUI",
65
+ "Theme",
66
+ "derive_theme",
67
+ "lift",
68
+ "mix",
69
+ "resolve_easing",
70
+ "theme_for",
71
+ "VSplit",
72
+ ]