kwebui 0.11.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.
Files changed (127) hide show
  1. kwebui-0.11.1/.gitignore +42 -0
  2. kwebui-0.11.1/LICENSE +201 -0
  3. kwebui-0.11.1/PKG-INFO +311 -0
  4. kwebui-0.11.1/README.md +277 -0
  5. kwebui-0.11.1/docs/architecture.md +120 -0
  6. kwebui-0.11.1/docs/images/showcase-overview.png +0 -0
  7. kwebui-0.11.1/docs/images/widget-alert-error.png +0 -0
  8. kwebui-0.11.1/docs/images/widget-alert-info.png +0 -0
  9. kwebui-0.11.1/docs/images/widget-alert-success.png +0 -0
  10. kwebui-0.11.1/docs/images/widget-alert-warning.png +0 -0
  11. kwebui-0.11.1/docs/images/widget-badge.png +0 -0
  12. kwebui-0.11.1/docs/images/widget-button.png +0 -0
  13. kwebui-0.11.1/docs/images/widget-checkbox.png +0 -0
  14. kwebui-0.11.1/docs/images/widget-columns.png +0 -0
  15. kwebui-0.11.1/docs/images/widget-container.png +0 -0
  16. kwebui-0.11.1/docs/images/widget-empty.png +0 -0
  17. kwebui-0.11.1/docs/images/widget-file-uploader.png +0 -0
  18. kwebui-0.11.1/docs/images/widget-html.png +0 -0
  19. kwebui-0.11.1/docs/images/widget-image.png +0 -0
  20. kwebui-0.11.1/docs/images/widget-imagestream.png +0 -0
  21. kwebui-0.11.1/docs/images/widget-json.png +0 -0
  22. kwebui-0.11.1/docs/images/widget-listbox.png +0 -0
  23. kwebui-0.11.1/docs/images/widget-progressbar.png +0 -0
  24. kwebui-0.11.1/docs/images/widget-sidebar.png +0 -0
  25. kwebui-0.11.1/docs/images/widget-slider.png +0 -0
  26. kwebui-0.11.1/docs/images/widget-spinner.png +0 -0
  27. kwebui-0.11.1/docs/images/widget-table.png +0 -0
  28. kwebui-0.11.1/docs/images/widget-text.png +0 -0
  29. kwebui-0.11.1/docs/images/widget-textedit.png +0 -0
  30. kwebui-0.11.1/docs/images/widget-toast.png +0 -0
  31. kwebui-0.11.1/docs/images/widget-topbar.png +0 -0
  32. kwebui-0.11.1/docs/images/widget-workflow-tracker.png +0 -0
  33. kwebui-0.11.1/docs/user-guide.md +962 -0
  34. kwebui-0.11.1/examples/assets/brand_theme.css +14 -0
  35. kwebui-0.11.1/examples/assets/sample.png +0 -0
  36. kwebui-0.11.1/examples/custom_theme.py +41 -0
  37. kwebui-0.11.1/examples/daheng_demo.py +395 -0
  38. kwebui-0.11.1/examples/demo.py +29 -0
  39. kwebui-0.11.1/examples/demo_check_id.py +40 -0
  40. kwebui-0.11.1/examples/demo_multi_container.py +88 -0
  41. kwebui-0.11.1/examples/demo_nonblocking.py +159 -0
  42. kwebui-0.11.1/examples/mjpeg_demo.py +102 -0
  43. kwebui-0.11.1/examples/showcase.py +277 -0
  44. kwebui-0.11.1/examples/workflow.py +85 -0
  45. kwebui-0.11.1/kwebui/__init__.py +33 -0
  46. kwebui-0.11.1/kwebui/app.py +264 -0
  47. kwebui-0.11.1/kwebui/events.py +19 -0
  48. kwebui-0.11.1/kwebui/frontend/static/css/base.css +678 -0
  49. kwebui-0.11.1/kwebui/frontend/static/js/app.js +9 -0
  50. kwebui-0.11.1/kwebui/frontend/static/js/core.js +91 -0
  51. kwebui-0.11.1/kwebui/frontend/static/js/renderer.js +53 -0
  52. kwebui-0.11.1/kwebui/frontend/static/js/shortkeys.js +94 -0
  53. kwebui-0.11.1/kwebui/frontend/static/js/vendor/vue.global.js +18844 -0
  54. kwebui-0.11.1/kwebui/frontend/static/js/websocket.js +35 -0
  55. kwebui-0.11.1/kwebui/frontend/static/js/widgets/alert.js +16 -0
  56. kwebui-0.11.1/kwebui/frontend/static/js/widgets/badge.js +17 -0
  57. kwebui-0.11.1/kwebui/frontend/static/js/widgets/button.js +29 -0
  58. kwebui-0.11.1/kwebui/frontend/static/js/widgets/checkbox.js +16 -0
  59. kwebui-0.11.1/kwebui/frontend/static/js/widgets/columns.js +24 -0
  60. kwebui-0.11.1/kwebui/frontend/static/js/widgets/container.js +106 -0
  61. kwebui-0.11.1/kwebui/frontend/static/js/widgets/empty.js +9 -0
  62. kwebui-0.11.1/kwebui/frontend/static/js/widgets/file_uploader.js +49 -0
  63. kwebui-0.11.1/kwebui/frontend/static/js/widgets/html.js +6 -0
  64. kwebui-0.11.1/kwebui/frontend/static/js/widgets/image.js +23 -0
  65. kwebui-0.11.1/kwebui/frontend/static/js/widgets/imagestream.js +19 -0
  66. kwebui-0.11.1/kwebui/frontend/static/js/widgets/json.js +6 -0
  67. kwebui-0.11.1/kwebui/frontend/static/js/widgets/listbox.js +41 -0
  68. kwebui-0.11.1/kwebui/frontend/static/js/widgets/popup.js +46 -0
  69. kwebui-0.11.1/kwebui/frontend/static/js/widgets/progressbar.js +10 -0
  70. kwebui-0.11.1/kwebui/frontend/static/js/widgets/sidebar.js +51 -0
  71. kwebui-0.11.1/kwebui/frontend/static/js/widgets/slider.js +43 -0
  72. kwebui-0.11.1/kwebui/frontend/static/js/widgets/spinner.js +21 -0
  73. kwebui-0.11.1/kwebui/frontend/static/js/widgets/table.js +28 -0
  74. kwebui-0.11.1/kwebui/frontend/static/js/widgets/text.js +18 -0
  75. kwebui-0.11.1/kwebui/frontend/static/js/widgets/textedit.js +50 -0
  76. kwebui-0.11.1/kwebui/frontend/static/js/widgets/toast.js +27 -0
  77. kwebui-0.11.1/kwebui/frontend/static/js/widgets/topbar.js +22 -0
  78. kwebui-0.11.1/kwebui/frontend/static/js/widgets/workflow_tracker.js +32 -0
  79. kwebui-0.11.1/kwebui/frontend/templates/index.html +23 -0
  80. kwebui-0.11.1/kwebui/page.py +45 -0
  81. kwebui-0.11.1/kwebui/plugin.py +82 -0
  82. kwebui-0.11.1/kwebui/registry.py +57 -0
  83. kwebui-0.11.1/kwebui/renderer.py +24 -0
  84. kwebui-0.11.1/kwebui/router.py +80 -0
  85. kwebui-0.11.1/kwebui/session.py +33 -0
  86. kwebui-0.11.1/kwebui/state.py +50 -0
  87. kwebui-0.11.1/kwebui/theme.py +20 -0
  88. kwebui-0.11.1/kwebui/themes/dark.css +9 -0
  89. kwebui-0.11.1/kwebui/themes/light.css +9 -0
  90. kwebui-0.11.1/kwebui/websocket.py +55 -0
  91. kwebui-0.11.1/kwebui/widget.py +112 -0
  92. kwebui-0.11.1/kwebui/widgets/__init__.py +6 -0
  93. kwebui-0.11.1/kwebui/widgets/alert.py +85 -0
  94. kwebui-0.11.1/kwebui/widgets/badge.py +66 -0
  95. kwebui-0.11.1/kwebui/widgets/button.py +108 -0
  96. kwebui-0.11.1/kwebui/widgets/checkbox.py +47 -0
  97. kwebui-0.11.1/kwebui/widgets/columns.py +147 -0
  98. kwebui-0.11.1/kwebui/widgets/container.py +306 -0
  99. kwebui-0.11.1/kwebui/widgets/empty.py +68 -0
  100. kwebui-0.11.1/kwebui/widgets/file_uploader.py +108 -0
  101. kwebui-0.11.1/kwebui/widgets/html.py +30 -0
  102. kwebui-0.11.1/kwebui/widgets/image.py +69 -0
  103. kwebui-0.11.1/kwebui/widgets/imagestream.py +156 -0
  104. kwebui-0.11.1/kwebui/widgets/json.py +26 -0
  105. kwebui-0.11.1/kwebui/widgets/listbox.py +59 -0
  106. kwebui-0.11.1/kwebui/widgets/popup.py +90 -0
  107. kwebui-0.11.1/kwebui/widgets/progressbar.py +34 -0
  108. kwebui-0.11.1/kwebui/widgets/sidebar.py +80 -0
  109. kwebui-0.11.1/kwebui/widgets/slider.py +57 -0
  110. kwebui-0.11.1/kwebui/widgets/spinner.py +69 -0
  111. kwebui-0.11.1/kwebui/widgets/table.py +123 -0
  112. kwebui-0.11.1/kwebui/widgets/text.py +39 -0
  113. kwebui-0.11.1/kwebui/widgets/textedit.py +64 -0
  114. kwebui-0.11.1/kwebui/widgets/toast.py +62 -0
  115. kwebui-0.11.1/kwebui/widgets/topbar.py +76 -0
  116. kwebui-0.11.1/kwebui/widgets/workflow_tracker.py +114 -0
  117. kwebui-0.11.1/kwebui.egg-info/PKG-INFO +311 -0
  118. kwebui-0.11.1/kwebui.egg-info/SOURCES.txt +125 -0
  119. kwebui-0.11.1/kwebui.egg-info/dependency_links.txt +1 -0
  120. kwebui-0.11.1/kwebui.egg-info/requires.txt +15 -0
  121. kwebui-0.11.1/kwebui.egg-info/scm_file_list.json +120 -0
  122. kwebui-0.11.1/kwebui.egg-info/scm_version.json +8 -0
  123. kwebui-0.11.1/kwebui.egg-info/top_level.txt +1 -0
  124. kwebui-0.11.1/pyproject.toml +76 -0
  125. kwebui-0.11.1/setup.cfg +4 -0
  126. kwebui-0.11.1/tests/test_badge.py +78 -0
  127. kwebui-0.11.1/tests/test_container_direction.py +64 -0
@@ -0,0 +1,42 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .eggs/
6
+ build/
7
+ dist/
8
+
9
+ # Virtual environments
10
+ .venv/
11
+ venv/
12
+ env/
13
+
14
+ # Testing
15
+ .pytest_cache/
16
+ .coverage
17
+ htmlcov/
18
+
19
+ # Tooling caches
20
+ .mypy_cache/
21
+ .ruff_cache/
22
+
23
+ # Editors / OS
24
+ .vscode/
25
+ .idea/
26
+ .DS_Store
27
+
28
+ # Local env / secrets
29
+ .env
30
+
31
+ ../*.jpg
32
+
33
+ graphify-out
34
+ decisions.md
35
+ milestones.md
36
+
37
+ docs/class-diagram.md
38
+ #docs/architecture.md
39
+
40
+ tests/
41
+
42
+ Readme
kwebui-0.11.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the
44
+ purposes of this License, Derivative Works shall not include works
45
+ that remain separable from, or merely link (or bind by name) to the
46
+ interfaces of, the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including the
49
+ original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing
141
+ the origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Kaptura GmbH
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
kwebui-0.11.1/PKG-INFO ADDED
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: kwebui
3
+ Version: 0.11.1
4
+ Summary: Build web UIs in pure Python. A clean, plugin-oriented alternative to Streamlit.
5
+ Author: Ahmad Karambakhsh
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Kaptura-GmbH/kwebui
8
+ Project-URL: Repository, https://github.com/Kaptura-GmbH/kwebui
9
+ Project-URL: Issues, https://github.com/Kaptura-GmbH/kwebui/issues
10
+ Project-URL: Documentation, https://github.com/Kaptura-GmbH/kwebui/blob/master/docs/user-guide.md
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: fastapi>=0.110
22
+ Requires-Dist: uvicorn[standard]>=0.29
23
+ Requires-Dist: jinja2>=3.1
24
+ Requires-Dist: websockets>=12.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: httpx>=0.27; extra == "dev"
28
+ Provides-Extra: imagestream
29
+ Requires-Dist: opencv-python-headless>=4.9; extra == "imagestream"
30
+ Requires-Dist: numpy>=1.26; extra == "imagestream"
31
+ Provides-Extra: file-uploader
32
+ Requires-Dist: python-multipart>=0.0.9; extra == "file-uploader"
33
+ Dynamic: license-file
34
+
35
+ # kwebui
36
+
37
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
38
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
39
+ [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)
40
+
41
+ **Build web UIs in pure Python — no HTML, CSS, or JavaScript required.**
42
+
43
+ kwebui is a clean, plugin-oriented alternative to Streamlit: every widget is a
44
+ self-contained plugin, the core framework knows nothing about individual
45
+ widgets, and the whole thing is small enough to read in an afternoon (see
46
+ [`docs/architecture.md`](docs/architecture.md)). A **retained tree** of
47
+ widgets lives server-side; mutating one pushes a single, minimal JSON patch
48
+ over a WebSocket to every connected browser — no full-page reruns, no
49
+ diffing a virtual DOM on every keystroke.
50
+
51
+ ```python
52
+ from kwebui import KApp
53
+
54
+ class Demo(KApp):
55
+ def build(self):
56
+ self.text("Hello World", size=28)
57
+ self.button("Click Me", on_click=lambda: print("Clicked"))
58
+
59
+ Demo(title="Demo").run()
60
+ ```
61
+
62
+ ![The full showcase app, every widget on one page](docs/images/showcase-overview.png)
63
+
64
+ ## Table of contents
65
+
66
+ - [Why kwebui](#why-kwebui)
67
+ - [Installation](#installation)
68
+ - [Quickstart](#quickstart)
69
+ - [User guide](#user-guide)
70
+ - [Widgets](#widgets)
71
+ - [Themes](#themes)
72
+ - [Packaging / installing elsewhere](#packaging--installing-elsewhere)
73
+ - [Project layout](#project-layout)
74
+ - [Session model — please read before production use](#session-model)
75
+ - [Contributing](#contributing)
76
+ - [License](#license)
77
+
78
+ ## Why kwebui
79
+
80
+ - **Pure Python.** No HTML/CSS/JS to write, no separate frontend build step,
81
+ no Node.js/npm involved anywhere — `pip install -e .` is enough.
82
+ - **Plugin-oriented core.** Every widget (`text`, `button`, `table`,
83
+ `container`, ...) is a self-contained plugin under `kwebui/widgets/`,
84
+ auto-discovered at startup. Delete every file under `widgets/` and `KApp`
85
+ still imports and runs — the core genuinely has no special knowledge of
86
+ any individual widget type.
87
+ - **Retained tree, not rerun-the-script.** Widgets are live Python objects
88
+ you mutate directly (`widget.set_text(...)`, `widget.update(...)`) — not
89
+ something you recreate on every interaction. Each mutation ships exactly
90
+ one minimal patch to connected browsers.
91
+ - **Small enough to actually read.** The core (`app.py`, `widget.py`,
92
+ `plugin.py`, `renderer.py`, `registry.py`) is a few hundred lines total.
93
+ See [`docs/architecture.md`](docs/architecture.md).
94
+ - **No CDN, no build tools.** The frontend is Vue 3, vendored as a single
95
+ `vue.global.js` file and loaded directly — components are plain JS
96
+ objects with template strings, not `.vue` Single File Components.
97
+
98
+ ## Installation
99
+
100
+ Requires Python 3.12+.
101
+
102
+ ```bash
103
+ python3.12 -m venv .venv
104
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
105
+ pip install -e . # add [dev] for tests, [imagestream] for OpenCV demos, [file_uploader] for uploads
106
+ ```
107
+
108
+ Or straight from GitHub, no local clone needed:
109
+
110
+ ```bash
111
+ pip install "git+https://github.com/Kaptura-GmbH/kwebui.git"
112
+ ```
113
+
114
+ See [`docs/user-guide.md`](docs/user-guide.md#1-install-kwebui-as-a-package)
115
+ for every install path (editable, from git, or as a built wheel).
116
+
117
+ ## Quickstart
118
+
119
+ ```bash
120
+ python examples/demo.py # the snippet above
121
+ python examples/showcase.py # every built-in widget on one page
122
+ python examples/workflow.py # topbar + workflow_tracker driving which page a container() shows
123
+ python examples/custom_theme.py # a theme CSS file shipped from your own project, not the kwebui package
124
+ python examples/mjpeg_demo.py # live MJPEG stream + snapshot capture (needs [imagestream])
125
+ python examples/daheng_demo.py # Daheng camera picker + live config (needs gxipy, see its docstring)
126
+ ```
127
+
128
+ Open the printed URL (default `http://127.0.0.1:8701`, or the next free
129
+ port after it if 8701 is already taken) in a browser.
130
+
131
+ ## User guide
132
+
133
+ See [`docs/user-guide.md`](docs/user-guide.md) for the full walkthrough
134
+ with a real screenshot for every widget. The short version:
135
+
136
+ 1. Subclass `KApp` and override `build()` to construct the page **once**
137
+ by calling widget methods on `self` (`self.text(...)`, `self.button(...)`,
138
+ ...) — `build()` runs automatically when you instantiate the class.
139
+ Then call `MyApp(title="...").run()`.
140
+ 2. Every widget method returns a live widget object. Store it on `self`
141
+ to change it later — from a callback, a background thread, or
142
+ anywhere else — and the browser updates automatically, without a
143
+ full page reload:
144
+
145
+ ```python
146
+ class Demo(KApp):
147
+ def build(self):
148
+ self.greeting = self.text("Hello")
149
+ self.button("Again", on_click=self.say_again)
150
+
151
+ def say_again(self):
152
+ self.greeting.set_text("Hello again") # pushes a minimal patch to every browser
153
+ ```
154
+ 3. Callbacks (`on_click`, `on_change`, ...) are plain Python functions
155
+ that run on the server, each on its own worker thread — the browser
156
+ only ever sends events, so a blocking callback never freezes the UI
157
+ for other connected browsers.
158
+ 4. Advanced: inside a callback, `self.session` gives you the connection
159
+ that triggered it (`self.session.state` is a free scratchpad dict).
160
+ Most apps never need this.
161
+
162
+ ## Widgets
163
+
164
+ For the full, illustrated version of this table — a real screenshot for
165
+ every widget, plus the install-and-run walkthrough in more depth — see
166
+ [`docs/user-guide.md`](docs/user-guide.md).
167
+
168
+ | Widget | Example (inside `build()`, called on `self`) |
169
+ |---|---|
170
+ | Text | `self.text("Hi", size=24, color="red", bold=True, italic=False, align="left")` |
171
+ | Button | `self.button("Save", on_click=save, enabled=True, shortkey="ctrl+k", color="red", text_color="white")` — `shortkey` binds a keyboard combo (`"k"`, `"shift+k"`, `"ctrl+k"`, `"shift+ctrl+k"`) that calls `on_click`, but only while the button is visible and enabled; `color`/`text_color` accept any CSS color and default to the theme's `--sg-button-bg`/`--sg-button-text-color` variables (an explicit value overrides just that button) |
172
+ | Checkbox | `self.checkbox("Enable feature", checked=False, on_change=lambda v: ...)` |
173
+ | TextEdit | `self.textedit("Name", placeholder="Jane", multiline=False, password=False, on_change=lambda v: ..., on_enter=lambda v: ...)` |
174
+ | Slider | `self.slider("Volume", min_value=0, max_value=100, value=50, on_change=lambda v: ...)` |
175
+ | ListBox | `self.listbox(["A", "B", "C"], on_select=lambda item: ...)` |
176
+ | ProgressBar | `self.progressbar(50)` / `self.progressbar(0, indeterminate=True)` |
177
+ | Spinner | `with self.spinner("Working...", show_time=True): do_slow_thing()` |
178
+ | Image | `self.image("cat.jpg", width=150)` / `self.image("cat.jpg", stretch=True)` — `width` (-1/0 = natural size, default) resizes the viewer; `stretch=True` fills the parent container's width instead. Local paths and URLs both work |
179
+ | ImageStream | `self.imagestream(frame_provider=capture_jpeg, fps=15)` — live MJPEG feed (webcam/OpenCV); or call `stream.push_frame(jpeg_bytes)` yourself. Same `width`/`stretch` as Image. `stream.latest_frame()` returns the most recent JPEG bytes (see `examples/mjpeg_demo.py` for a snapshot-capture button) |
180
+ | FileUploader | `self.file_uploader("Upload a file", accept=".csv", on_upload=lambda filename, data: ...)` — needs the `[file_uploader]` extra installed; without it, uploads return a clear error instead of failing |
181
+ | Html | `self.html("<strong>Raw HTML</strong>")` — trusts the string, don't pass unsanitized user input |
182
+ | Json | `self.json({"status": "ok", "items": [1, 2, 3]})` — pretty-printed, read-only |
183
+ | Table | `self.table([{"name": "Alice", "age": 30}], width=-1, stretch=False, border=True, hide_header=False)` — read-only dataframe-style grid; also accepts a dict of columns, a list of lists + `columns=...`, or a real `pandas.DataFrame` (detected by shape, no pandas dependency added) |
184
+ | Empty | `slot = self.empty(); slot.text("Loading..."); slot.progressbar(80)` — a placeholder whose content can be swapped in place |
185
+ | Container | `page = self.container(width=300, height=-1, stretch=False, border=True, border_roundness=True, caption="Settings", direction="vertical", wrap=False, horizontal_alignment=None, vertical_alignment=None, shortkey=None, on_keypress=None, vertical_padding=None, horizontal_padding=None); page.text("Hi"); page.button("Go"); ...; page.clear()` — like `Empty`, but holds a whole group of widgets instead of one; `.clear()` wipes it before rebuilding with different content. `direction="horizontal"` lines children up side by side (each at its own natural size) instead of stacked — unlike `columns(n)`'s fixed-width slots — and `wrap=True` lets them flow onto further lines once a row no longer fits, e.g. a row of `Badge`s. `horizontal_alignment`/`vertical_alignment` (`"left"/"center"/"right"` and `"top"/"center"/"bottom"`) position children within a fixed `width`/`height`, e.g. a "panel" with a centered button — their meaning stays tied to the horizontal/vertical axis regardless of `direction`. `shortkey` works like Button's, but calls `on_keypress` (there's no `on_click` to reuse) and only fires while the container is visible. `vertical_padding`/`horizontal_padding` (px) default to the theme's `--sg-container-padding-vertical`/`--sg-container-padding-horizontal` variables (`10px` each); an explicit value (including `0`) overrides just that container |
186
+ | Success / Info / Warning / Error | `self.success("Saved!")`, `self.info(...)`, `self.warning(...)`, `self.error(...)` — colored status banners |
187
+ | Badge | `self.badge("New")` / `self.badge("Active", icon="✅", color="success")` — a small pill-shaped status/tag label; `color` is `success`/`info`/`warning`/`error` (same colors as the banners above) or `None` for neutral |
188
+ | Toast | `self.toast("Saved!", level="success")` — a transient corner notification |
189
+ | Columns | `left, right = self.columns(2)` — side-by-side containers, each accepting the same widget calls as `self`; or `narrow, wide = self.columns([0.3, 0.7])` for relative widths (weights must be positive and sum to 1) |
190
+ | Sidebar | `nav = self.sidebar()` — a persistent panel pinned to the left edge, collapsible by default |
191
+ | Popup | `self.popup("Discard changes?", kind="yesno", on_return=lambda answer: ...)` — a modal dialog; `kind` is `ok`, `okcancel`, `yesno`, or `yesnocancel` |
192
+ | WorkflowTracker | `self.workflow_tracker(tasks, orientation="horizontal", on_select=lambda task_id: ...)` — a step tracker; each task is `{"id", "title", "status", "detail"}` |
193
+ | Topbar | `bar = self.topbar(); bar.workflow_tracker(tasks)` — a full-width panel pinned to the top of the page, sticky by default |
194
+
195
+ Every widget returned by `self.<widget>(...)` has an `.update(**props)`
196
+ method plus typed setters (e.g. `text.set_text(...)`, `checkbox.set_checked(...)`).
197
+ Every widget also has, regardless of type:
198
+
199
+ ```python
200
+ self.name.highlight() # outline in the theme's default color (red)
201
+ self.name.highlight("#16a34a") # or a specific color, for this widget only
202
+ self.name.unhighlight()
203
+
204
+ self.name.focus() # send keyboard focus to it
205
+
206
+ self.name.hide() # visually hide it (stays in the tree, keeps its state)
207
+ self.name.show() # reveal it again
208
+ self.name.remove() # drop it from the page and server memory for good
209
+ ```
210
+
211
+ ## Themes
212
+
213
+ ```python
214
+ self.set_theme("dark") # or "light" (default)
215
+ ```
216
+
217
+ Themes are plain CSS files. The bundled ones live in `kwebui/themes/` —
218
+ add a third by dropping a `themes/<name>.css` file there defining the
219
+ same `--sg-*` custom properties as `light.css`/`dark.css`. `--sg-highlight`
220
+ is the default color `.highlight()` uses when called without an explicit
221
+ color.
222
+
223
+ `set_theme()` also accepts a path to a CSS file anywhere in your own
224
+ project, not bundled with kwebui at all — `self.set_theme("assets/brand.css")`.
225
+ Its name becomes that file's own stem (`brand.css` → `"brand"`); pass
226
+ that name again later to switch back to it. See
227
+ [`docs/user-guide.md`](docs/user-guide.md#8-themes) for the full
228
+ behavior (when it takes effect, live reload from disk, ...) and
229
+ `examples/custom_theme.py` for a runnable example.
230
+
231
+ Some `--sg-*` variables are structural defaults rather than
232
+ theme-specific colors — `--sg-button-bg`/`--sg-button-text-color`
233
+ (`button`'s `color`/`text_color` defaults) and
234
+ `--sg-container-padding-vertical`/`--sg-container-padding-horizontal`
235
+ (`container`'s padding defaults, `10px` each) live once in `base.css`'s
236
+ `:root` and apply across every theme. Override them in a custom
237
+ stylesheet to change the default everywhere at once, or pass the
238
+ matching widget parameter to override just one instance.
239
+
240
+ ## Packaging / installing elsewhere
241
+
242
+ This is a standard `pyproject.toml` package, so any of these work:
243
+
244
+ ```bash
245
+ # Editable install for local development (what the steps above do)
246
+ pip install -e .
247
+
248
+ # Build a distributable wheel + sdist
249
+ pip install build
250
+ python -m build # writes dist/kwebui-<version>-py3-none-any.whl
251
+ pip install dist/kwebui-<version>-py3-none-any.whl # on any machine with that wheel
252
+
253
+ # Install straight from this repository (no PyPI needed)
254
+ pip install "git+https://github.com/Kaptura-GmbH/kwebui.git"
255
+ ```
256
+
257
+ To embed kwebui in another app: `pip install` it into that app's own
258
+ venv the same way, then `from kwebui import KApp` as usual — there is
259
+ no separate "export" step, the package *is* the deliverable.
260
+
261
+ ## Project layout
262
+
263
+ See [`docs/architecture.md`](docs/architecture.md) for the plugin system,
264
+ rendering pipeline, event flow, and session model, and
265
+ [`docs/class-diagram.md`](docs/class-diagram.md) for a Mermaid class
266
+ diagram of the core framework and every built-in widget plugin.
267
+
268
+ The frontend (`kwebui/frontend/static/`) is Vue 3, loaded as a single
269
+ `vue.global.js` file (vendored under `static/js/vendor/`, no CDN) rather
270
+ than Single File Components — this keeps `pip install -e .` free of any
271
+ Node.js/npm involvement, at the cost of writing components as plain JS
272
+ objects with template strings instead of `.vue` files. Each widget type
273
+ is still its own file under `frontend/static/js/widgets/`, auto-discovered
274
+ and injected as a `<script>` tag the same way the Python side auto-discovers
275
+ plugins.
276
+
277
+ ## Session model
278
+
279
+ > [!IMPORTANT]
280
+ > All browsers connected to a running app share the *same* live widget
281
+ > tree — this is a broadcast/dashboard model (like a kiosk or control
282
+ > panel), **not** Streamlit's per-tab isolated state. Great for "one
283
+ > screen, several viewers" — control panels, dashboards, kiosks; not
284
+ > meant for multi-tenant apps where each visitor should see their own
285
+ > private data.
286
+
287
+ This is a deliberate simplification, not an oversight: true per-session
288
+ isolation would mean cloning the widget tree per connection and
289
+ re-binding every callback closure to the clone, which is a lot of
290
+ machinery for a library meant to be readable in an afternoon. `Session`
291
+ is still its own class internally, so per-session isolation could be
292
+ added later without an API break — see
293
+ [`docs/architecture.md`](docs/architecture.md#5-sessions) for the
294
+ reasoning in full.
295
+
296
+ ## Contributing
297
+
298
+ Issues and pull requests are welcome. Before opening a PR:
299
+
300
+ 1. For anything touching rendering, layout, or an interactive round-trip
301
+ (click → server → browser), verify it in a real browser — several
302
+ real bugs in this codebase's history were invisible in a code read and
303
+ obvious in a screenshot.
304
+ 2. Keep changes scoped: a bug fix doesn't need surrounding refactors, and
305
+ a new widget should follow the existing plugin pattern (see
306
+ [`docs/architecture.md`](docs/architecture.md) and any existing
307
+ `kwebui/widgets/*.py` file as a template).
308
+
309
+ ## License
310
+
311
+ Apache License 2.0. See [LICENSE](LICENSE).