Hopsakee commited on
Commit
403335b
·
0 Parent(s):

first commit

Browse files
.github/workflows/deploy.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to GitHub Pages
2
+
3
+ permissions:
4
+ contents: write
5
+ pages: write
6
+
7
+ on:
8
+ push:
9
+ branches: [ "main", "master" ]
10
+ workflow_dispatch:
11
+ jobs:
12
+ deploy:
13
+ runs-on: ubuntu-latest
14
+ steps: [uses: fastai/workflows/quarto-ghp@master]
.github/workflows/test.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ name: CI
2
+ on: [workflow_dispatch, pull_request, push]
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ steps: [uses: fastai/workflows/nbdev-ci@master]
.gitignore ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ _docs/
2
+ _proc/
3
+
4
+ *.bak
5
+ .gitattributes
6
+ .last_checked
7
+ .gitconfig
8
+ *.bak
9
+ *.log
10
+ *~
11
+ ~*
12
+ _tmp*
13
+ tmp*
14
+ tags
15
+ *.pkg
16
+
17
+ # Byte-compiled / optimized / DLL files
18
+ __pycache__/
19
+ *.py[cod]
20
+ *$py.class
21
+
22
+ # C extensions
23
+ *.so
24
+
25
+ # Distribution / packaging
26
+ .Python
27
+ env/
28
+ build/
29
+ conda/
30
+ develop-eggs/
31
+ dist/
32
+ downloads/
33
+ eggs/
34
+ .eggs/
35
+ lib/
36
+ lib64/
37
+ parts/
38
+ sdist/
39
+ var/
40
+ wheels/
41
+ *.egg-info/
42
+ .installed.cfg
43
+ *.egg
44
+
45
+ # PyInstaller
46
+ # Usually these files are written by a python script from a template
47
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
48
+ *.manifest
49
+ *.spec
50
+
51
+ # Installer logs
52
+ pip-log.txt
53
+ pip-delete-this-directory.txt
54
+
55
+ # Unit test / coverage reports
56
+ htmlcov/
57
+ .tox/
58
+ .coverage
59
+ .coverage.*
60
+ .cache
61
+ nosetests.xml
62
+ coverage.xml
63
+ *.cover
64
+ .hypothesis/
65
+
66
+ # Translations
67
+ *.mo
68
+ *.pot
69
+
70
+ # Django stuff:
71
+ *.log
72
+ local_settings.py
73
+
74
+ # Flask stuff:
75
+ instance/
76
+ .webassets-cache
77
+
78
+ # Scrapy stuff:
79
+ .scrapy
80
+
81
+ # Sphinx documentation
82
+ docs/_build/
83
+
84
+ # PyBuilder
85
+ target/
86
+
87
+ # Jupyter Notebook
88
+ .ipynb_checkpoints
89
+
90
+ # pyenv
91
+ .python-version
92
+
93
+ # celery beat schedule file
94
+ celerybeat-schedule
95
+
96
+ # SageMath parsed files
97
+ *.sage.py
98
+
99
+ # dotenv
100
+ .env
101
+
102
+ # virtualenv
103
+ .venv
104
+ venv/
105
+ ENV/
106
+
107
+ # Spyder project settings
108
+ .spyderproject
109
+ .spyproject
110
+
111
+ # Rope project settings
112
+ .ropeproject
113
+
114
+ # mkdocs documentation
115
+ /site
116
+
117
+ # mypy
118
+ .mypy_cache/
119
+
120
+ .vscode
121
+ *.swp
122
+
123
+ # osx generated files
124
+ .DS_Store
125
+ .DS_Store?
126
+ .Trashes
127
+ ehthumbs.db
128
+ Thumbs.db
129
+ .idea
130
+
131
+ # pytest
132
+ .pytest_cache
133
+
134
+ # tools/trust-doc-nbs
135
+ docs_src/.last_checked
136
+
137
+ # symlinks to fastai
138
+ docs_src/fastai
139
+ tools/fastai
140
+
141
+ # link checker
142
+ checklink/cookies.txt
143
+
144
+ # .gitconfig is now autogenerated
145
+ .gitconfig
146
+
147
+ # Quarto installer
148
+ .deb
149
+ .pkg
150
+
151
+ # Quarto
152
+ .quarto
.pdm-python ADDED
@@ -0,0 +1 @@
 
 
1
+ /home/jelle/code/app_starter_gui/.venv/bin/python
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 purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the 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 the
141
+ 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 2022, fastai
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.
MANIFEST.in ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ include settings.ini
2
+ include LICENSE
3
+ include CONTRIBUTING.md
4
+ include README.md
5
+ recursive-exclude * __pycache__
README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hopsakee/app_starter_gui
2
+
3
+
4
+ <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
+
6
+ This file will become your README and also the index of your
7
+ documentation.
8
+
9
+ ## Developer Guide
10
+
11
+ If you are new to using `nbdev` here are some useful pointers to get you
12
+ started.
13
+
14
+ ### Install Hopsakee/app_starter_gui in Development mode
15
+
16
+ ``` sh
17
+ # make sure Hopsakee/app_starter_gui package is installed in development mode
18
+ $ pip install -e .
19
+
20
+ # make changes under nbs/ directory
21
+ # ...
22
+
23
+ # compile to have changes apply to Hopsakee/app_starter_gui
24
+ $ nbdev_prepare
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Installation
30
+
31
+ Install latest from the GitHub
32
+ [repository](https://github.com/Hopsakee/Hopsakee/app_starter_gui):
33
+
34
+ ``` sh
35
+ $ pip install git+https://github.com/Hopsakee/Hopsakee/app_starter_gui.git
36
+ ```
37
+
38
+ or from [conda](https://anaconda.org/Hopsakee/Hopsakee/app_starter_gui)
39
+
40
+ ``` sh
41
+ $ conda install -c Hopsakee Hopsakee/app_starter_gui
42
+ ```
43
+
44
+ or from [pypi](https://pypi.org/project/Hopsakee/app_starter_gui/)
45
+
46
+ ``` sh
47
+ $ pip install Hopsakee/app_starter_gui
48
+ ```
49
+
50
+ ### Documentation
51
+
52
+ Documentation can be found hosted on this GitHub
53
+ [repository](https://github.com/Hopsakee/Hopsakee/app_starter_gui)’s
54
+ [pages](https://Hopsakee.github.io/Hopsakee/app_starter_gui/).
55
+ Additionally you can find package manager specific guidelines on
56
+ [conda](https://anaconda.org/Hopsakee/Hopsakee/app_starter_gui) and
57
+ [pypi](https://pypi.org/project/Hopsakee/app_starter_gui/) respectively.
58
+
59
+ ## How to use
60
+
61
+ Fill me in please! Don’t forget code examples:
62
+
63
+ ``` python
64
+ 1+1
65
+ ```
66
+
67
+ 2
app_starter_gui/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ __version__ = "0.0.1"
app_starter_gui/_modidx.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Autogenerated by nbdev
2
+
3
+ d = { 'settings': { 'branch': 'main',
4
+ 'doc_baseurl': '/app_starter_gui',
5
+ 'doc_host': 'https://Hopsakee.github.io',
6
+ 'git_url': 'https://github.com/Hopsakee/app_starter_gui',
7
+ 'lib_path': 'app_starter_gui'},
8
+ 'syms': { 'app_starter_gui.core': { 'app_starter_gui.core.Button': ('core.html#button', 'app_starter_gui/core.py'),
9
+ 'app_starter_gui.core.load_buttons': ('core.html#load_buttons', 'app_starter_gui/core.py'),
10
+ 'app_starter_gui.core.save_buttons': ('core.html#save_buttons', 'app_starter_gui/core.py'),
11
+ 'app_starter_gui.core.test_save_load': ('core.html#test_save_load', 'app_starter_gui/core.py')},
12
+ 'app_starter_gui.css': { 'app_starter_gui.css.generate_css': ('css.html#generate_css', 'app_starter_gui/css.py'),
13
+ 'app_starter_gui.css.test_generate_css': ('css.html#test_generate_css', 'app_starter_gui/css.py')},
14
+ 'app_starter_gui.gradio_app': { 'app_starter_gui.gradio_app.create_app': ( 'gradio_app.html#create_app',
15
+ 'app_starter_gui/gradio_app.py'),
16
+ 'app_starter_gui.gradio_app.test_create_app': ( 'gradio_app.html#test_create_app',
17
+ 'app_starter_gui/gradio_app.py')}}}
app_starter_gui/core.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Core functionality for button management"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
4
+
5
+ # %% auto 0
6
+ __all__ = ['Button', 'save_buttons', 'load_buttons', 'test_save_load']
7
+
8
+ # %% ../nbs/00_core.ipynb 2
9
+ from dataclasses import dataclass
10
+ import yaml
11
+ from pathlib import Path
12
+
13
+ # %% ../nbs/00_core.ipynb 4
14
+ @dataclass
15
+ class Button:
16
+ """A button with label, image, link, and type"""
17
+ label: str
18
+ image_url: str
19
+ link_url: str
20
+ app_type: str
21
+
22
+ # %% ../nbs/00_core.ipynb 5
23
+ def save_buttons(buttons, file='buttons.yaml'):
24
+ """Save buttons to YAML file
25
+
26
+ Args:
27
+ buttons: List of Button objects
28
+ file: Path to YAML file (default: 'buttons.yaml')
29
+ """
30
+ button_data = [vars(b) for b in buttons]
31
+ with open(file, 'w') as f:
32
+ yaml.safe_dump(button_data, f)
33
+
34
+ # %% ../nbs/00_core.ipynb 6
35
+ def load_buttons(file='buttons.yaml'):
36
+ """Load buttons from YAML file
37
+
38
+ Args:
39
+ file: Path to YAML file (default: 'buttons.yaml')
40
+ Returns:
41
+ List of Button objects
42
+ """
43
+ if not Path(file).exists():
44
+ return []
45
+ with open(file) as f:
46
+ button_data = yaml.safe_load(f)
47
+ return [Button(**data) for data in button_data]
48
+
49
+ # %% ../nbs/00_core.ipynb 8
50
+ from fastcore.test import *
51
+
52
+ def test_save_load():
53
+ "Test that buttons save and load correctly"
54
+ test_buttons = [
55
+ Button("Test1", "img1.jpg", "http://test1.com", "Type1"),
56
+ Button("Test2", "img2.jpg", "http://test2.com", "Type2")
57
+ ]
58
+ save_buttons(test_buttons, "test_buttons.yaml")
59
+ loaded_buttons = load_buttons("test_buttons.yaml")
60
+ test_eq(len(loaded_buttons), len(test_buttons))
61
+ test_eq(loaded_buttons[0].label, "Test1")
62
+ test_eq(loaded_buttons[0].app_type, "Type1")
63
+ test_eq(loaded_buttons[1].label, "Test2")
64
+ test_eq(loaded_buttons[1].app_type, "Type2")
65
+
66
+ test_save_load()
app_starter_gui/css.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """CSS generation for button styling"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_css.ipynb.
4
+
5
+ # %% auto 0
6
+ __all__ = ['generate_css', 'test_generate_css']
7
+
8
+ # %% ../nbs/01_css.ipynb 2
9
+ from .core import Button
10
+ from fastcore.test import * # for test_assert
11
+
12
+ # %% ../nbs/01_css.ipynb 4
13
+ def generate_css(buttons):
14
+ """Generate CSS styling for buttons with image backgrounds
15
+
16
+ Args:
17
+ buttons: List of Button objects
18
+ Returns:
19
+ str: CSS styling with unique button IDs and hover effects
20
+
21
+ Each button gets:
22
+ - 230px height (180px image + 50px label)
23
+ - Hover animation with lift effect
24
+ - Image zoom on hover
25
+ - Rounded corners
26
+ """
27
+ css_template = """
28
+ #{btn_id} {{
29
+ height: 230px; /* Total height of button */
30
+ width: 200px;
31
+ border-radius: 15px;
32
+ display: flex;
33
+ flex-direction: column;
34
+ padding: 0;
35
+ margin: 0;
36
+ overflow: hidden;
37
+ transition: transform 0.2s, box-shadow 0.2s;
38
+ background: none;
39
+ }}
40
+
41
+ #{btn_id}::before {{
42
+ content: '';
43
+ height: 180px; /* Image height */
44
+ width: 100%;
45
+ background-size: cover;
46
+ background-position: center center;
47
+ background-repeat: no-repeat;
48
+ background-image: url('{image_url}');
49
+ transition: transform 0.2s;
50
+ margin: 0;
51
+ padding: 0;
52
+ display: block;
53
+ flex-shrink: 0;
54
+ position: relative;
55
+ top: 0;
56
+ border-radius: 15px 15px 0 0; /* Round top corners only */
57
+ }}
58
+
59
+ #{btn_id}:hover {{
60
+ transform: translateY(-5px);
61
+ box-shadow: 0 5px 15px rgba(0,0,0,0.3);
62
+ }}
63
+
64
+ #{btn_id} > div {{
65
+ height: 50px;
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: center;
69
+ }}
70
+
71
+ #{btn_id}:hover::before {{
72
+ transform: scale(1.05);
73
+ }}
74
+ """
75
+
76
+ all_css = []
77
+ for i, button in enumerate(buttons, 1):
78
+ btn_id = f"btn{i}"
79
+ css = css_template.format(btn_id=btn_id, image_url=button.image_url)
80
+ all_css.append(css)
81
+
82
+ return "\n".join(all_css)
83
+
84
+ # %% ../nbs/01_css.ipynb 6
85
+ from fastcore.test import *
86
+
87
+ def test_generate_css():
88
+ "Test CSS generation includes all app types"
89
+ buttons = [
90
+ Button("AI App", "img.jpg", "https://ai.com", "AI"),
91
+ Button("Search", "img.jpg", "https://search.com", "Search")
92
+ ]
93
+ css = generate_css(buttons)
94
+ test('#btn1', css.lower(), lambda x,y: x in y)
95
+ test('#btn2', css.lower(), lambda x,y: x in y)
96
+
97
+ test_generate_css()
app_starter_gui/gradio_app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Creation of the Gradio GUI for the app"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_gradio_app.ipynb.
4
+
5
+ # %% auto 0
6
+ __all__ = ['create_app', 'test_create_app']
7
+
8
+ # %% ../nbs/02_gradio_app.ipynb 2
9
+ import gradio as gr
10
+ from .core import Button, load_buttons
11
+ from .css import generate_css
12
+
13
+ # %% ../nbs/02_gradio_app.ipynb 4
14
+ def create_app(yaml_file='buttons.yaml', css_generator=generate_css):
15
+ """Create a Gradio dashboard for the button interface
16
+
17
+ Args:
18
+ yaml_file: Path to YAML file containing button data (default: 'buttons.yaml')
19
+ css_generator: Function to generate CSS (default: generate_css)
20
+ Returns:
21
+ gr.Blocks: Gradio interface
22
+ """
23
+ buttons = load_buttons(yaml_file)
24
+ css = generate_css(buttons)
25
+
26
+ with gr.Blocks(css=css) as blocks:
27
+ with gr.Column():
28
+ gr.HTML('<div class="button-grid">' +
29
+ ''.join([f'''
30
+ <a href="{b.link_url}" class="{b.app_type.lower()}">
31
+ <img src="{b.image_url}" style="max-width:100%"/>
32
+ <p>{b.label}</p>
33
+ </a>''' for b in buttons]) +
34
+ '</div>')
35
+ return blocks
36
+
37
+ # %% ../nbs/02_gradio_app.ipynb 6
38
+ from fastcore.test import *
39
+
40
+ def test_create_app():
41
+ "Test app creation with example buttons"
42
+ app = create_app('test_buttons.yaml')
43
+ test(app, gr.Blocks, isinstance)
44
+
45
+ test_create_app()
buttons.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ - label: Find Fabric
2
+ image_url: https://github.com/danielmiessler/fabric/blob/main/images/fabric-logo-gif.gif?raw=true
3
+ link_url: https://huggingface.co/spaces/Hopsakee/fabric_to_espanso
4
+ app_type: Prompt
5
+ - label: Jaws of the Lion
6
+ image_url: google.jpg
7
+ link_url: https://notebooklm.google.com/notebook/ac6595f8-963c-4bd8-87cf-26b7007434a6?_gl=1*10y09ch*_ga*OTQ0NDQwODcwLjE3MzUzNzU4MDc.*_ga_W0LDH41ZCB*MTczNjk3MjM5NS43LjAuMTczNjk3MjM5NS4wLjAuMA..
8
+ app_type: Bordspel
nbs/.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
15
+ OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
16
+ jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
17
+ qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
18
+ rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
19
+ HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
20
+ hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
21
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
22
+ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
23
+ NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
24
+ ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
25
+ TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
26
+ jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
27
+ oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
nbs/00_core.ipynb ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# core\n",
8
+ "\n",
9
+ "> Core functionality for button management"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": 11,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "#| default_exp core"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": 21,
24
+ "metadata": {},
25
+ "outputs": [],
26
+ "source": [
27
+ "#| export\n",
28
+ "#| hide\n",
29
+ "from dataclasses import dataclass\n",
30
+ "import yaml\n",
31
+ "from pathlib import Path"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": 13,
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "#| hide\n",
41
+ "from nbdev.showdoc import show_doc"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": 14,
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "#| export\n",
51
+ "@dataclass\n",
52
+ "class Button:\n",
53
+ " \"\"\"A button with label, image, link, and type\"\"\"\n",
54
+ " label: str\n",
55
+ " image_url: str\n",
56
+ " link_url: str\n",
57
+ " app_type: str"
58
+ ]
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": 15,
63
+ "metadata": {},
64
+ "outputs": [],
65
+ "source": [
66
+ "#| export\n",
67
+ "def save_buttons(buttons, file='buttons.yaml'):\n",
68
+ " \"\"\"Save buttons to YAML file\n",
69
+ " \n",
70
+ " Args:\n",
71
+ " buttons: List of Button objects\n",
72
+ " file: Path to YAML file (default: 'buttons.yaml')\n",
73
+ " \"\"\"\n",
74
+ " button_data = [vars(b) for b in buttons]\n",
75
+ " with open(file, 'w') as f:\n",
76
+ " yaml.safe_dump(button_data, f)"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": 16,
82
+ "metadata": {},
83
+ "outputs": [],
84
+ "source": [
85
+ "#| export\n",
86
+ "def load_buttons(file='buttons.yaml'):\n",
87
+ " \"\"\"Load buttons from YAML file\n",
88
+ " \n",
89
+ " Args:\n",
90
+ " file: Path to YAML file (default: 'buttons.yaml')\n",
91
+ " Returns:\n",
92
+ " List of Button objects\n",
93
+ " \"\"\"\n",
94
+ " if not Path(file).exists():\n",
95
+ " return []\n",
96
+ " with open(file) as f:\n",
97
+ " button_data = yaml.safe_load(f)\n",
98
+ " return [Button(**data) for data in button_data]"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "code",
103
+ "execution_count": 17,
104
+ "metadata": {},
105
+ "outputs": [],
106
+ "source": [
107
+ "# Example usage\n",
108
+ "example_buttons = [\n",
109
+ " Button(\n",
110
+ " label=\"ChatGPT\",\n",
111
+ " image_url=\"https://example.com/chatgpt.jpg\",\n",
112
+ " link_url=\"https://chat.openai.com\",\n",
113
+ " app_type=\"AI\"\n",
114
+ " ),\n",
115
+ " Button(\n",
116
+ " label=\"Google\",\n",
117
+ " image_url=\"https://example.com/google.jpg\",\n",
118
+ " link_url=\"https://google.com\",\n",
119
+ " app_type=\"Search\"\n",
120
+ " )\n",
121
+ "]\n",
122
+ "\n",
123
+ "# Save example buttons\n",
124
+ "save_buttons(example_buttons, \"test_buttons.yaml\")\n",
125
+ "\n",
126
+ "# Load and test\n",
127
+ "loaded_buttons = load_buttons(\"test_buttons.yaml\")"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": 22,
133
+ "metadata": {},
134
+ "outputs": [],
135
+ "source": [
136
+ "#| export\n",
137
+ "#| hide\n",
138
+ "from fastcore.test import *\n",
139
+ "\n",
140
+ "def test_save_load():\n",
141
+ " \"Test that buttons save and load correctly\"\n",
142
+ " test_buttons = [\n",
143
+ " Button(\"Test1\", \"img1.jpg\", \"http://test1.com\", \"Type1\"),\n",
144
+ " Button(\"Test2\", \"img2.jpg\", \"http://test2.com\", \"Type2\")\n",
145
+ " ]\n",
146
+ " save_buttons(test_buttons, \"test_buttons.yaml\")\n",
147
+ " loaded_buttons = load_buttons(\"test_buttons.yaml\")\n",
148
+ " test_eq(len(loaded_buttons), len(test_buttons))\n",
149
+ " test_eq(loaded_buttons[0].label, \"Test1\")\n",
150
+ " test_eq(loaded_buttons[0].app_type, \"Type1\")\n",
151
+ " test_eq(loaded_buttons[1].label, \"Test2\")\n",
152
+ " test_eq(loaded_buttons[1].app_type, \"Type2\")\n",
153
+ "\n",
154
+ "test_save_load()"
155
+ ]
156
+ },
157
+ {
158
+ "cell_type": "code",
159
+ "execution_count": 19,
160
+ "metadata": {},
161
+ "outputs": [],
162
+ "source": [
163
+ "#| hide\n",
164
+ "Path(\"test_buttons.yaml\").unlink(missing_ok=True)"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": 20,
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "#| hide\n",
174
+ "import nbdev; nbdev.nbdev_export()"
175
+ ]
176
+ }
177
+ ],
178
+ "metadata": {
179
+ "kernelspec": {
180
+ "display_name": ".venv",
181
+ "language": "python",
182
+ "name": "python3"
183
+ },
184
+ "language_info": {
185
+ "codemirror_mode": {
186
+ "name": "ipython",
187
+ "version": 3
188
+ },
189
+ "file_extension": ".py",
190
+ "mimetype": "text/x-python",
191
+ "name": "python",
192
+ "nbconvert_exporter": "python",
193
+ "pygments_lexer": "ipython3",
194
+ "version": "3.11.0rc1"
195
+ }
196
+ },
197
+ "nbformat": 4,
198
+ "nbformat_minor": 4
199
+ }
nbs/01_css.ipynb ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# CSS\n",
8
+ "> CSS generation for button styling"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 1,
14
+ "metadata": {},
15
+ "outputs": [],
16
+ "source": [
17
+ "#| default_exp css"
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "execution_count": 2,
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "ename": "ModuleNotFoundError",
27
+ "evalue": "No module named 'app_starter_gui.core'",
28
+ "output_type": "error",
29
+ "traceback": [
30
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
31
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
32
+ "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#| hide\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mapp_starter_gui\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcore\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Button\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mfastcore\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtest\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m \u001b[38;5;66;03m# for test_assert\u001b[39;00m\n",
33
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'app_starter_gui.core'"
34
+ ]
35
+ }
36
+ ],
37
+ "source": [
38
+ "#| export\n",
39
+ "#| hide\n",
40
+ "from app_starter_gui.core import Button\n",
41
+ "from fastcore.test import * # for test_assert"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": 2,
47
+ "metadata": {},
48
+ "outputs": [],
49
+ "source": [
50
+ "from nbdev.showdoc import show_doc"
51
+ ]
52
+ },
53
+ {
54
+ "cell_type": "code",
55
+ "execution_count": 3,
56
+ "metadata": {},
57
+ "outputs": [],
58
+ "source": [
59
+ "#| export\n",
60
+ "def generate_css(buttons):\n",
61
+ " \"\"\"Generate CSS styling for buttons with image backgrounds\n",
62
+ " \n",
63
+ " Args:\n",
64
+ " buttons: List of Button objects\n",
65
+ " Returns:\n",
66
+ " str: CSS styling with unique button IDs and hover effects\n",
67
+ " \n",
68
+ " Each button gets:\n",
69
+ " - 230px height (180px image + 50px label)\n",
70
+ " - Hover animation with lift effect\n",
71
+ " - Image zoom on hover\n",
72
+ " - Rounded corners\n",
73
+ " \"\"\"\n",
74
+ " css_template = \"\"\"\n",
75
+ " #{btn_id} {{ \n",
76
+ " height: 230px; /* Total height of button */\n",
77
+ " width: 200px;\n",
78
+ " border-radius: 15px;\n",
79
+ " display: flex;\n",
80
+ " flex-direction: column;\n",
81
+ " padding: 0;\n",
82
+ " margin: 0;\n",
83
+ " overflow: hidden;\n",
84
+ " transition: transform 0.2s, box-shadow 0.2s;\n",
85
+ " background: none;\n",
86
+ " }}\n",
87
+ " \n",
88
+ " #{btn_id}::before {{\n",
89
+ " content: '';\n",
90
+ " height: 180px; /* Image height */\n",
91
+ " width: 100%;\n",
92
+ " background-size: cover;\n",
93
+ " background-position: center center;\n",
94
+ " background-repeat: no-repeat;\n",
95
+ " background-image: url('{image_url}');\n",
96
+ " transition: transform 0.2s;\n",
97
+ " margin: 0;\n",
98
+ " padding: 0;\n",
99
+ " display: block;\n",
100
+ " flex-shrink: 0;\n",
101
+ " position: relative;\n",
102
+ " top: 0;\n",
103
+ " border-radius: 15px 15px 0 0; /* Round top corners only */\n",
104
+ " }}\n",
105
+ " \n",
106
+ " #{btn_id}:hover {{\n",
107
+ " transform: translateY(-5px);\n",
108
+ " box-shadow: 0 5px 15px rgba(0,0,0,0.3);\n",
109
+ " }}\n",
110
+ "\n",
111
+ " #{btn_id} > div {{\n",
112
+ " height: 50px;\n",
113
+ " display: flex;\n",
114
+ " align-items: center;\n",
115
+ " justify-content: center;\n",
116
+ " }}\n",
117
+ "\n",
118
+ " #{btn_id}:hover::before {{\n",
119
+ " transform: scale(1.05);\n",
120
+ " }}\n",
121
+ " \"\"\"\n",
122
+ " \n",
123
+ " all_css = []\n",
124
+ " for i, button in enumerate(buttons, 1):\n",
125
+ " btn_id = f\"btn{i}\"\n",
126
+ " css = css_template.format(btn_id=btn_id, image_url=button.image_url)\n",
127
+ " all_css.append(css)\n",
128
+ " \n",
129
+ " return \"\\n\".join(all_css)"
130
+ ]
131
+ },
132
+ {
133
+ "cell_type": "code",
134
+ "execution_count": 5,
135
+ "metadata": {},
136
+ "outputs": [
137
+ {
138
+ "ename": "NameError",
139
+ "evalue": "name 'Button' is not defined",
140
+ "output_type": "error",
141
+ "traceback": [
142
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
143
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
144
+ "Cell \u001b[0;32mIn[5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Example usage\u001b[39;00m\n\u001b[1;32m 2\u001b[0m buttons \u001b[38;5;241m=\u001b[39m [\n\u001b[0;32m----> 3\u001b[0m \u001b[43mButton\u001b[49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI App\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mimg.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://ai.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m 4\u001b[0m Button(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSearch Engine\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mimg.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://search.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSearch\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 5\u001b[0m ]\n\u001b[1;32m 7\u001b[0m css \u001b[38;5;241m=\u001b[39m generate_css(buttons)\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(css)\n",
145
+ "\u001b[0;31mNameError\u001b[0m: name 'Button' is not defined"
146
+ ]
147
+ }
148
+ ],
149
+ "source": [
150
+ "# Example usage\n",
151
+ "buttons = [\n",
152
+ " Button(\"AI App\", \"img.jpg\", \"https://ai.com\", \"AI\"),\n",
153
+ " Button(\"Search Engine\", \"img.jpg\", \"https://search.com\", \"Search\")\n",
154
+ "]\n",
155
+ "\n",
156
+ "css = generate_css(buttons)\n",
157
+ "print(css)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": 4,
163
+ "metadata": {},
164
+ "outputs": [
165
+ {
166
+ "ename": "NameError",
167
+ "evalue": "name 'Button' is not defined",
168
+ "output_type": "error",
169
+ "traceback": [
170
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
171
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
172
+ "Cell \u001b[0;32mIn[4], line 16\u001b[0m\n\u001b[1;32m 13\u001b[0m test(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m#btn2\u001b[39m\u001b[38;5;124m'\u001b[39m, css\u001b[38;5;241m.\u001b[39mlower(), \u001b[38;5;28;01mlambda\u001b[39;00m x,y: x \u001b[38;5;129;01min\u001b[39;00m y)\n\u001b[1;32m 14\u001b[0m test(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mgrid-template-columns\u001b[39m\u001b[38;5;124m'\u001b[39m, css, \u001b[38;5;28;01mlambda\u001b[39;00m x,y: x \u001b[38;5;129;01min\u001b[39;00m y)\n\u001b[0;32m---> 16\u001b[0m \u001b[43mtest_generate_css\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
173
+ "Cell \u001b[0;32mIn[4], line 8\u001b[0m, in \u001b[0;36mtest_generate_css\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21mtest_generate_css\u001b[39m():\n\u001b[1;32m 6\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTest CSS generation includes all app types\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 7\u001b[0m buttons \u001b[38;5;241m=\u001b[39m [\n\u001b[0;32m----> 8\u001b[0m \u001b[43mButton\u001b[49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI App\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mimg.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://ai.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI\u001b[39m\u001b[38;5;124m\"\u001b[39m),\n\u001b[1;32m 9\u001b[0m Button(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSearch\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mimg.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://search.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSearch\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 10\u001b[0m ]\n\u001b[1;32m 11\u001b[0m css \u001b[38;5;241m=\u001b[39m generate_css(buttons)\n\u001b[1;32m 12\u001b[0m test(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m#btn1\u001b[39m\u001b[38;5;124m'\u001b[39m, css\u001b[38;5;241m.\u001b[39mlower(), \u001b[38;5;28;01mlambda\u001b[39;00m x,y: x \u001b[38;5;129;01min\u001b[39;00m y)\n",
174
+ "\u001b[0;31mNameError\u001b[0m: name 'Button' is not defined"
175
+ ]
176
+ }
177
+ ],
178
+ "source": [
179
+ "#| export\n",
180
+ "#| hide\n",
181
+ "from fastcore.test import *\n",
182
+ "\n",
183
+ "def test_generate_css():\n",
184
+ " \"Test CSS generation includes all app types\"\n",
185
+ " buttons = [\n",
186
+ " Button(\"AI App\", \"img.jpg\", \"https://ai.com\", \"AI\"),\n",
187
+ " Button(\"Search\", \"img.jpg\", \"https://search.com\", \"Search\")\n",
188
+ " ]\n",
189
+ " css = generate_css(buttons)\n",
190
+ " test('#btn1', css.lower(), lambda x,y: x in y)\n",
191
+ " test('#btn2', css.lower(), lambda x,y: x in y)\n",
192
+ "\n",
193
+ "test_generate_css()"
194
+ ]
195
+ },
196
+ {
197
+ "cell_type": "code",
198
+ "execution_count": null,
199
+ "metadata": {},
200
+ "outputs": [],
201
+ "source": [
202
+ "#| hide\n",
203
+ "import nbdev; nbdev.nbdev_export()"
204
+ ]
205
+ }
206
+ ],
207
+ "metadata": {
208
+ "kernelspec": {
209
+ "display_name": ".venv",
210
+ "language": "python",
211
+ "name": "python3"
212
+ },
213
+ "language_info": {
214
+ "codemirror_mode": {
215
+ "name": "ipython",
216
+ "version": 3
217
+ },
218
+ "file_extension": ".py",
219
+ "mimetype": "text/x-python",
220
+ "name": "python",
221
+ "nbconvert_exporter": "python",
222
+ "pygments_lexer": "ipython3",
223
+ "version": "3.11.0rc1"
224
+ }
225
+ },
226
+ "nbformat": 4,
227
+ "nbformat_minor": 2
228
+ }
nbs/02_gradio_app.ipynb ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# gradio_app\n",
8
+ "> Creation of the Gradio GUI for the app"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 1,
14
+ "metadata": {},
15
+ "outputs": [],
16
+ "source": [
17
+ "#| default_exp gradio_app"
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "execution_count": 2,
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "ename": "ModuleNotFoundError",
27
+ "evalue": "No module named 'app_starter_gui'",
28
+ "output_type": "error",
29
+ "traceback": [
30
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
31
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
32
+ "Cell \u001b[0;32mIn[2], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m#| hide\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mgradio\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mgr\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mapp_starter_gui\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcore\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Button, load_buttons\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mapp_starter_gui\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcss\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m generate_css\n",
33
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'app_starter_gui'"
34
+ ]
35
+ }
36
+ ],
37
+ "source": [
38
+ "#| export\n",
39
+ "#| hide\n",
40
+ "import gradio as gr\n",
41
+ "from app_starter_gui.core import Button, load_buttons\n",
42
+ "from app_starter_gui.css import generate_css"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": null,
48
+ "metadata": {},
49
+ "outputs": [],
50
+ "source": [
51
+ "#| hide\n",
52
+ "from nbdev.showdoc import show_doc"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "#| export\n",
62
+ "def create_app(yaml_file='buttons.yaml', css_generator=generate_css):\n",
63
+ " \"\"\"Create a Gradio dashboard for the button interface\n",
64
+ " \n",
65
+ " Args:\n",
66
+ " yaml_file: Path to YAML file containing button data (default: 'buttons.yaml')\n",
67
+ " css_generator: Function to generate CSS (default: generate_css)\n",
68
+ " Returns:\n",
69
+ " gr.Blocks: Gradio interface\n",
70
+ " \"\"\"\n",
71
+ " buttons = load_buttons(yaml_file)\n",
72
+ " css = generate_css(buttons)\n",
73
+ " \n",
74
+ " with gr.Blocks(css=css) as blocks:\n",
75
+ " with gr.Column():\n",
76
+ " gr.HTML('<div class=\"button-grid\">' + \n",
77
+ " ''.join([f'''\n",
78
+ " <a href=\"{b.link_url}\" class=\"{b.app_type.lower()}\">\n",
79
+ " <img src=\"{b.image_url}\" style=\"max-width:100%\"/>\n",
80
+ " <p>{b.label}</p>\n",
81
+ " </a>''' for b in buttons]) +\n",
82
+ " '</div>')\n",
83
+ " return blocks"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "code",
88
+ "execution_count": null,
89
+ "metadata": {},
90
+ "outputs": [],
91
+ "source": [
92
+ "# Example usage\n",
93
+ "app = create_app('test_buttons.yaml')"
94
+ ]
95
+ },
96
+ {
97
+ "cell_type": "code",
98
+ "execution_count": null,
99
+ "metadata": {},
100
+ "outputs": [],
101
+ "source": [
102
+ "#| export\n",
103
+ "#| hide\n",
104
+ "from fastcore.test import *\n",
105
+ "\n",
106
+ "def test_create_app():\n",
107
+ " \"Test app creation with example buttons\"\n",
108
+ " app = create_app('test_buttons.yaml')\n",
109
+ " test(app, gr.Blocks, isinstance)\n",
110
+ " \n",
111
+ "test_create_app()"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "code",
116
+ "execution_count": null,
117
+ "metadata": {},
118
+ "outputs": [],
119
+ "source": [
120
+ "#| hide\n",
121
+ "import nbdev; nbdev.nbdev_export()"
122
+ ]
123
+ }
124
+ ],
125
+ "metadata": {
126
+ "kernelspec": {
127
+ "display_name": ".venv",
128
+ "language": "python",
129
+ "name": "python3"
130
+ },
131
+ "language_info": {
132
+ "codemirror_mode": {
133
+ "name": "ipython",
134
+ "version": 3
135
+ },
136
+ "file_extension": ".py",
137
+ "mimetype": "text/x-python",
138
+ "name": "python",
139
+ "nbconvert_exporter": "python",
140
+ "pygments_lexer": "ipython3",
141
+ "version": "3.11.0rc1"
142
+ }
143
+ },
144
+ "nbformat": 4,
145
+ "nbformat_minor": 2
146
+ }
nbs/_quarto.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ project:
2
+ type: website
3
+
4
+ format:
5
+ html:
6
+ theme: cosmo
7
+ css: styles.css
8
+ toc: true
9
+ keep-md: true
10
+ commonmark: default
11
+
12
+ website:
13
+ twitter-card: true
14
+ open-graph: true
15
+ repo-actions: [issue]
16
+ navbar:
17
+ background: primary
18
+ search: true
19
+ sidebar:
20
+ style: floating
21
+
22
+ metadata-files: [nbdev.yml, sidebar.yml]
nbs/index.ipynb ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "#| hide\n",
10
+ "from app_starter_gui.core import *"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "metadata": {},
16
+ "source": [
17
+ "# Hopsakee/app_starter_gui\n",
18
+ "\n",
19
+ "> A simple GUI to quickly switch to URL-apps I often use."
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "markdown",
24
+ "metadata": {},
25
+ "source": [
26
+ "This file will become your README and also the index of your documentation."
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "markdown",
31
+ "metadata": {},
32
+ "source": [
33
+ "## Developer Guide"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "markdown",
38
+ "metadata": {},
39
+ "source": [
40
+ "If you are new to using `nbdev` here are some useful pointers to get you started."
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "markdown",
45
+ "metadata": {},
46
+ "source": [
47
+ "### Install Hopsakee/app_starter_gui in Development mode"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "markdown",
52
+ "metadata": {},
53
+ "source": [
54
+ "```sh\n",
55
+ "# make sure Hopsakee/app_starter_gui package is installed in development mode\n",
56
+ "$ pip install -e .\n",
57
+ "# if using PDM you should probably use\n",
58
+ "$ pdm install\n",
59
+ "\n",
60
+ "# make changes under nbs/ directory\n",
61
+ "# ...\n",
62
+ "\n",
63
+ "# compile to have changes apply to Hopsakee/app_starter_gui\n",
64
+ "$ nbdev_prepare\n",
65
+ "# if using PDM you should probably first explicitly activate the project environment\n",
66
+ "$ eval $(pdm venv activate in-project)\n",
67
+ "```"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "markdown",
72
+ "metadata": {},
73
+ "source": [
74
+ "## Usage"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "markdown",
79
+ "metadata": {},
80
+ "source": [
81
+ "### Installation"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "markdown",
86
+ "metadata": {},
87
+ "source": [
88
+ "Install latest from the GitHub [repository][repo]:\n",
89
+ "\n",
90
+ "```sh\n",
91
+ "$ pip install git+https://github.com/Hopsakee/Hopsakee/app_starter_gui.git\n",
92
+ "```\n",
93
+ "\n",
94
+ "or from [conda][conda]\n",
95
+ "\n",
96
+ "```sh\n",
97
+ "$ conda install -c Hopsakee Hopsakee/app_starter_gui\n",
98
+ "```\n",
99
+ "\n",
100
+ "or from [pypi][pypi]\n",
101
+ "\n",
102
+ "\n",
103
+ "```sh\n",
104
+ "$ pip install Hopsakee/app_starter_gui\n",
105
+ "```\n",
106
+ "\n",
107
+ "\n",
108
+ "[repo]: https://github.com/Hopsakee/Hopsakee/app_starter_gui\n",
109
+ "[docs]: https://Hopsakee.github.io/Hopsakee/app_starter_gui/\n",
110
+ "[pypi]: https://pypi.org/project/Hopsakee/app_starter_gui/\n",
111
+ "[conda]: https://anaconda.org/Hopsakee/Hopsakee/app_starter_gui"
112
+ ]
113
+ },
114
+ {
115
+ "cell_type": "markdown",
116
+ "metadata": {},
117
+ "source": [
118
+ "### Documentation"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "markdown",
123
+ "metadata": {},
124
+ "source": [
125
+ "Documentation can be found hosted on this GitHub [repository][repo]'s [pages][docs]. Additionally you can find package manager specific guidelines on [conda][conda] and [pypi][pypi] respectively.\n",
126
+ "\n",
127
+ "[repo]: https://github.com/Hopsakee/Hopsakee/app_starter_gui\n",
128
+ "[docs]: https://Hopsakee.github.io/Hopsakee/app_starter_gui/\n",
129
+ "[pypi]: https://pypi.org/project/Hopsakee/app_starter_gui/\n",
130
+ "[conda]: https://anaconda.org/Hopsakee/Hopsakee/app_starter_gui"
131
+ ]
132
+ },
133
+ {
134
+ "cell_type": "markdown",
135
+ "metadata": {},
136
+ "source": [
137
+ "## How to use"
138
+ ]
139
+ },
140
+ {
141
+ "cell_type": "markdown",
142
+ "metadata": {},
143
+ "source": [
144
+ "### Basic example:"
145
+ ]
146
+ },
147
+ {
148
+ "cell_type": "code",
149
+ "execution_count": 4,
150
+ "metadata": {},
151
+ "outputs": [
152
+ {
153
+ "ename": "ModuleNotFoundError",
154
+ "evalue": "No module named 'app_starter_gui'",
155
+ "output_type": "error",
156
+ "traceback": [
157
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
158
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
159
+ "Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mapp_starter_gui\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcore\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m Button \n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mapp_starter_gui\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mgradio_app\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m create_app\n",
160
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'app_starter_gui'"
161
+ ]
162
+ }
163
+ ],
164
+ "source": [
165
+ "from app_starter_gui.core import Button \n",
166
+ "from app_starter_gui.gradio_app import create_app"
167
+ ]
168
+ },
169
+ {
170
+ "cell_type": "markdown",
171
+ "metadata": {},
172
+ "source": [
173
+ "### Create some buttons\n",
174
+ "\n",
175
+ "#### In the codebase:"
176
+ ]
177
+ },
178
+ {
179
+ "cell_type": "code",
180
+ "execution_count": 2,
181
+ "metadata": {},
182
+ "outputs": [
183
+ {
184
+ "ename": "NameError",
185
+ "evalue": "name 'Button' is not defined",
186
+ "output_type": "error",
187
+ "traceback": [
188
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
189
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
190
+ "Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m buttons \u001b[38;5;241m=\u001b[39m [ \u001b[43mButton\u001b[49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mChatGPT\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mchatgpt.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://chat.openai.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAI\u001b[39m\u001b[38;5;124m\"\u001b[39m), Button(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGoogle\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgoogle.jpg\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://google.com\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSearch\u001b[39m\u001b[38;5;124m\"\u001b[39m) ]\n",
191
+ "\u001b[0;31mNameError\u001b[0m: name 'Button' is not defined"
192
+ ]
193
+ }
194
+ ],
195
+ "source": [
196
+ "buttons = [ Button(\"ChatGPT\", \"chatgpt.jpg\", \"https://chat.openai.com\", \"AI\"), Button(\"Google\", \"google.jpg\", \"https://google.com\", \"Search\") ]"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "markdown",
201
+ "metadata": {},
202
+ "source": [
203
+ "#### Configuration with YAML\n",
204
+ "\n",
205
+ "You can define your buttons in a YAML file (`buttons.yaml`):"
206
+ ]
207
+ },
208
+ {
209
+ "cell_type": "markdown",
210
+ "metadata": {},
211
+ "source": [
212
+ "```yaml\n",
213
+ "- label: ChatGPT\n",
214
+ " image_url: chatgpt.jpg\n",
215
+ " link_url: https://chat.openai.com\n",
216
+ " app_type: AI\n",
217
+ "- label: Google\n",
218
+ " image_url: google.jpg\n",
219
+ " link_url: https://google.com\n",
220
+ " app_type: Search\n",
221
+ "```"
222
+ ]
223
+ },
224
+ {
225
+ "cell_type": "markdown",
226
+ "metadata": {},
227
+ "source": [
228
+ "### Launch the App\n",
229
+ "\n",
230
+ "Load buttons from YAML and create the app:"
231
+ ]
232
+ },
233
+ {
234
+ "cell_type": "code",
235
+ "execution_count": null,
236
+ "metadata": {},
237
+ "outputs": [],
238
+ "source": [
239
+ "from app_starter_gui.gradio_app import create_app"
240
+ ]
241
+ },
242
+ {
243
+ "cell_type": "markdown",
244
+ "metadata": {},
245
+ "source": [
246
+ "Create and launch app from YAML"
247
+ ]
248
+ },
249
+ {
250
+ "cell_type": "code",
251
+ "execution_count": 3,
252
+ "metadata": {},
253
+ "outputs": [
254
+ {
255
+ "ename": "NameError",
256
+ "evalue": "name 'create_app' is not defined",
257
+ "output_type": "error",
258
+ "traceback": [
259
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
260
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
261
+ "Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m app \u001b[38;5;241m=\u001b[39m \u001b[43mcreate_app\u001b[49m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mbuttons.yaml\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 2\u001b[0m app\u001b[38;5;241m.\u001b[39mlaunch(share\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
262
+ "\u001b[0;31mNameError\u001b[0m: name 'create_app' is not defined"
263
+ ]
264
+ }
265
+ ],
266
+ "source": [
267
+ "app = create_app('buttons.yaml')\n",
268
+ "app.launch(share=True)"
269
+ ]
270
+ },
271
+ {
272
+ "cell_type": "markdown",
273
+ "metadata": {},
274
+ "source": [
275
+ "## Features\n",
276
+ "\n",
277
+ "- Define buttons with labels, images, links, and types\n",
278
+ "- Group buttons by type with automatic styling\n",
279
+ "- Responsive grid layout\n",
280
+ "- Load button configurations from YAML\n",
281
+ "- Customizable CSS for each button type"
282
+ ]
283
+ },
284
+ {
285
+ "cell_type": "markdown",
286
+ "metadata": {},
287
+ "source": [
288
+ "\n",
289
+ "## Customizing Layout\n",
290
+ "\n",
291
+ "The buttons are arranged in a responsive grid layout. You can customize this by modifying the CSS:"
292
+ ]
293
+ },
294
+ {
295
+ "cell_type": "code",
296
+ "execution_count": null,
297
+ "metadata": {},
298
+ "outputs": [],
299
+ "source": [
300
+ "from app_starter_gui.core import Button, save_buttons \n",
301
+ "from app_starter_gui.css import generate_css"
302
+ ]
303
+ },
304
+ {
305
+ "cell_type": "code",
306
+ "execution_count": null,
307
+ "metadata": {},
308
+ "outputs": [],
309
+ "source": [
310
+ "# Create custom CSS\n",
311
+ "def my_custom_css(buttons):\n",
312
+ " types = {b.app_type for b in buttons}\n",
313
+ " return \"\"\"\n",
314
+ " .button-grid {\n",
315
+ " display: grid;\n",
316
+ " grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* wider buttons */\n",
317
+ " gap: 2rem; /* more space between buttons */\n",
318
+ " padding: 2rem; /* more padding around grid */ \n",
319
+ " }\n",
320
+ " \"\"\"\n",
321
+ "\n",
322
+ "# Use custom CSS when creating app\n",
323
+ "app = create_app('buttons.yaml', css_generator=my_custom_css)"
324
+ ]
325
+ },
326
+ {
327
+ "cell_type": "markdown",
328
+ "metadata": {},
329
+ "source": [
330
+ "## Image URLs\n",
331
+ "\n",
332
+ "For button images, you must use either:\n",
333
+ "- URLs to images hosted online (e.g., `https://example.com/image.jpg`)\n",
334
+ "- URLs to images in your GitHub repository (e.g., `https://raw.githubusercontent.com/username/repo/main/images/icon.png`)\n",
335
+ "\n",
336
+ "Local file paths won't work because:\n",
337
+ "1. Gradio needs the images to be web-accessible\n",
338
+ "2. Other users won't have access to files on your local machine\n",
339
+ "\n",
340
+ "Example YAML with proper image URLs:\n",
341
+ "```yaml\n",
342
+ "- label: ChatGPT\n",
343
+ " image_url: https://raw.githubusercontent.com/your-repo/images/chatgpt-icon.png\n",
344
+ " link_url: https://chat.openai.com\n",
345
+ " app_type: AI\n",
346
+ "```"
347
+ ]
348
+ }
349
+ ],
350
+ "metadata": {
351
+ "kernelspec": {
352
+ "display_name": ".venv",
353
+ "language": "python",
354
+ "name": "python3"
355
+ },
356
+ "language_info": {
357
+ "codemirror_mode": {
358
+ "name": "ipython",
359
+ "version": 3
360
+ },
361
+ "file_extension": ".py",
362
+ "mimetype": "text/x-python",
363
+ "name": "python",
364
+ "nbconvert_exporter": "python",
365
+ "pygments_lexer": "ipython3",
366
+ "version": "3.11.0rc1"
367
+ }
368
+ },
369
+ "nbformat": 4,
370
+ "nbformat_minor": 4
371
+ }
nbs/nbdev.yml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ project:
2
+ output-dir: _docs
3
+
4
+ website:
5
+ title: "Hopsakee/app_starter_gui"
6
+ site-url: "https://Hopsakee.github.io/Hopsakee/app_starter_gui"
7
+ description: "A simple GUI to quickly switch to URL-apps I often use."
8
+ repo-branch: main
9
+ repo-url: "https://github.com/Hopsakee/Hopsakee/app_starter_gui"
nbs/styles.css ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .cell {
2
+ margin-bottom: 1rem;
3
+ }
4
+
5
+ .cell > .sourceCode {
6
+ margin-bottom: 0;
7
+ }
8
+
9
+ .cell-output > pre {
10
+ margin-bottom: 0;
11
+ }
12
+
13
+ .cell-output > pre, .cell-output > .sourceCode > pre, .cell-output-stdout > pre {
14
+ margin-left: 0.8rem;
15
+ margin-top: 0;
16
+ background: none;
17
+ border-left: 2px solid lightsalmon;
18
+ border-top-left-radius: 0;
19
+ border-top-right-radius: 0;
20
+ }
21
+
22
+ .cell-output > .sourceCode {
23
+ border: none;
24
+ }
25
+
26
+ .cell-output > .sourceCode {
27
+ background: none;
28
+ margin-top: 0;
29
+ }
30
+
31
+ div.description {
32
+ padding-left: 2px;
33
+ padding-top: 5px;
34
+ font-style: italic;
35
+ font-size: 135%;
36
+ opacity: 70%;
37
+ }
nbs/test_buttons.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ - app_type: Type1
2
+ image_url: img1.jpg
3
+ label: Test1
4
+ link_url: http://test1.com
5
+ - app_type: Type2
6
+ image_url: img2.jpg
7
+ label: Test2
8
+ link_url: http://test2.com
pdm.lock ADDED
The diff for this file is too large to render. See raw diff
 
pyproject.toml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "app_starter_gui"
3
+ version = "0.0.1"
4
+ description = "A simple GUI to quickly switch to URL-apps I often use."
5
+ authors = [
6
+ {name = "Hopsakee", email = "[email protected]"},
7
+ {name = "Jelle de Jong", email = "[email protected]"},
8
+ ]
9
+ dependencies = [
10
+ "nbdev>=2.3.34",
11
+ "gradio>=5.12.0",
12
+ "jupyterlab-quarto>=0.3.5",
13
+ "jupyter>=1.1.1",
14
+ "jupyterlab>=4.3.4",
15
+ "pyyaml>=6.0.2",
16
+ "fastcore>=1.7.28",
17
+ ]
18
+ requires-python = ">=3.7"
19
+ readme = "README.md"
20
+ license = {text = "Apache Software License 2.0"}
21
+ keywords = ["nbdev jupyter notebook python"]
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Intended Audience :: Developers",
25
+ "License :: OSI Approved :: Apache Software License",
26
+ "Natural Language :: English",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.7",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ ]
34
+
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/Hopsakee/app_starter_gui"
38
+
39
+ [project.optional-dependencies]
40
+ dev = []
41
+
42
+ [project.entry-points.nbdev]
43
+ app_starter_gui = "app_starter_gui._modidx:d"
44
+ [tool.pdm]
45
+ distribution = true
46
+
47
+ [build-system]
48
+ requires = ["pdm-backend"]
49
+ build-backend = "pdm.backend"
settings.ini ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [DEFAULT]
2
+ # All sections below are required unless otherwise specified.
3
+ # See https://github.com/AnswerDotAI/nbdev/blob/main/settings.ini for examples.
4
+
5
+ ### Python library ###
6
+ repo = app_starter_gui
7
+ lib_name = %(repo)s
8
+ version = 0.0.1
9
+ min_python = 3.7
10
+ license = apache2
11
+ black_formatting = False
12
+
13
+ ### nbdev ###
14
+ doc_path = _docs
15
+ lib_path = app_starter_gui
16
+ nbs_path = nbs
17
+ recursive = True
18
+ tst_flags = notest
19
+ put_version_in_init = True
20
+
21
+ ### Docs ###
22
+ branch = main
23
+ custom_sidebar = False
24
+ doc_host = https://%(user)s.github.io
25
+ doc_baseurl = /%(repo)s
26
+ git_url = https://github.com/%(user)s/%(repo)s
27
+ title = %(lib_name)s
28
+
29
+ ### PyPI ###
30
+ audience = Developers
31
+ author = Jelle de Jong
32
+ author_email = [email protected]
33
+ copyright = 2025 onwards, %(author)s
34
+ description = A simple GUI to quickly switch to URL-apps I often use.
35
+ keywords = nbdev jupyter notebook python
36
+ language = English
37
+ status = 3
38
+ user = Hopsakee
39
+
40
+ ### Optional ###
41
+ # requirements = fastcore pandas
42
+ # dev_requirements =
43
+ # console_scripts =
44
+ # conda_user =
45
+ # package_data =
setup.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pkg_resources import parse_version
2
+ from configparser import ConfigParser
3
+ import setuptools, shlex
4
+ assert parse_version(setuptools.__version__)>=parse_version('36.2')
5
+
6
+ # note: all settings are in settings.ini; edit there, not here
7
+ config = ConfigParser(delimiters=['='])
8
+ config.read('settings.ini', encoding='utf-8')
9
+ cfg = config['DEFAULT']
10
+
11
+ cfg_keys = 'version description keywords author author_email'.split()
12
+ expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
13
+ for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
14
+ setup_cfg = {o:cfg[o] for o in cfg_keys}
15
+
16
+ licenses = {
17
+ 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'),
18
+ 'mit': ('MIT License', 'OSI Approved :: MIT License'),
19
+ 'gpl2': ('GNU General Public License v2', 'OSI Approved :: GNU General Public License v2 (GPLv2)'),
20
+ 'gpl3': ('GNU General Public License v3', 'OSI Approved :: GNU General Public License v3 (GPLv3)'),
21
+ 'bsd3': ('BSD License', 'OSI Approved :: BSD License'),
22
+ }
23
+ statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
24
+ '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
25
+ py_versions = '3.6 3.7 3.8 3.9 3.10 3.11 3.12'.split()
26
+
27
+ requirements = shlex.split(cfg.get('requirements', ''))
28
+ if cfg.get('pip_requirements'): requirements += shlex.split(cfg.get('pip_requirements', ''))
29
+ min_python = cfg['min_python']
30
+ lic = licenses.get(cfg['license'].lower(), (cfg['license'], None))
31
+ dev_requirements = (cfg.get('dev_requirements') or '').split()
32
+
33
+ package_data = dict()
34
+ pkg_data = cfg.get('package_data', None)
35
+ if pkg_data:
36
+ package_data[cfg['lib_name']] = pkg_data.split() # split as multiple files might be listed
37
+ # Add package data to setup_cfg for setuptools.setup(..., **setup_cfg)
38
+ setup_cfg['package_data'] = package_data
39
+
40
+ setuptools.setup(
41
+ name = cfg['lib_name'],
42
+ license = lic[0],
43
+ classifiers = [
44
+ 'Development Status :: ' + statuses[int(cfg['status'])],
45
+ 'Intended Audience :: ' + cfg['audience'].title(),
46
+ 'Natural Language :: ' + cfg['language'].title(),
47
+ ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]] + (['License :: ' + lic[1] ] if lic[1] else []),
48
+ url = cfg['git_url'],
49
+ packages = setuptools.find_packages(),
50
+ include_package_data = True,
51
+ install_requires = requirements,
52
+ extras_require={ 'dev': dev_requirements },
53
+ dependency_links = cfg.get('dep_links','').split(),
54
+ python_requires = '>=' + cfg['min_python'],
55
+ long_description = open('README.md', encoding='utf-8').read(),
56
+ long_description_content_type = 'text/markdown',
57
+ zip_safe = False,
58
+ entry_points = {
59
+ 'console_scripts': cfg.get('console_scripts','').split(),
60
+ 'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d']
61
+ },
62
+ **setup_cfg)
63
+
64
+
tests/__init__.py ADDED
File without changes