Skip to content

Commit a9b6ed9

Browse files
Pascal Maximilian BremerPascal Maximilian Bremer
authored andcommitted
initial commit
0 parents  commit a9b6ed9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4252
-0
lines changed

.gitignore

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
parts/
18+
sdist/
19+
var/
20+
wheels/
21+
*.egg-info/
22+
.installed.cfg
23+
*.egg
24+
MANIFEST
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*.cover
45+
.hypothesis/
46+
.pytest_cache/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
db.sqlite3
56+
57+
# Flask stuff:
58+
instance/
59+
.webassets-cache
60+
61+
# Scrapy stuff:
62+
.scrapy
63+
64+
# Sphinx documentation
65+
docs/_build/
66+
67+
# PyBuilder
68+
target/
69+
70+
# Jupyter Notebook
71+
.ipynb_checkpoints
72+
73+
# pyenv
74+
.python-version
75+
76+
# celery beat schedule file
77+
celerybeat-schedule
78+
79+
# SageMath parsed files
80+
*.sage.py
81+
82+
# Environments
83+
.env
84+
.venv
85+
env/
86+
venv/
87+
ENV/
88+
env.bak/
89+
venv.bak/
90+
91+
# Spyder project settings
92+
.spyderproject
93+
.spyproject
94+
95+
# Rope project settings
96+
.ropeproject
97+
98+
# mkdocs documentation
99+
/site
100+
/docs
101+
102+
# mypy
103+
.mypy_cache/
104+
105+
# testing
106+
testing/
107+
.vscode/settings.json
108+
examples/
109+
110+
build/
111+
dist/

.gitlab-ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
stages:
2+
- test
3+
- deploy
4+
5+
.test:
6+
script:
7+
- "apk add --update git xvfb python3-tkinter build-base zlib-dev jpeg-dev"
8+
- "exec Xvfb :8 -screen 0 640x480x24 2>/tmp/Xvfb.log &"
9+
- "python -m venv /opt/venv"
10+
- "source /opt/venv/bin/activate; pip install --upgrade pip"
11+
- 'source /opt/venv/bin/activate; DISPLAY=:8 pip install -e ".[more_widgets,styles]"'
12+
- "source /opt/venv/bin/activate; DISPLAY=:8 python -m layoutx.install_tkdnd"
13+
- "source /opt/venv/bin/activate; DISPLAY=:8 python setup.py test"
14+
15+
test-3.7:
16+
extends: ".test"
17+
stage: "test"
18+
image: "python:3.7-alpine"
19+
20+
test-3.8:
21+
extends: ".test"
22+
stage: "test"
23+
image: "python:3.8-alpine"
24+
25+
pages:
26+
image: python:3.7-alpine
27+
script:
28+
- pip install -r requirements-docs.txt
29+
- mkdocs build
30+
artifacts:
31+
paths:
32+
- public
33+
stage: deploy
34+
only:
35+
- master
36+
37+
pypi:
38+
image: python:3
39+
stage: deploy
40+
cache: {}
41+
script:
42+
- pip install -U twine
43+
- python setup.py check sdist bdist # This will fail if your creds are bad.
44+
- python setup.py sdist bdist_wheel
45+
- twine upload dist/*
46+
only:
47+
- master

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
}
14+
]
15+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Pascal Maximilian Bremer
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include LICENSE
2+
include Readme.md
3+
include layoutx/resources/*.ico

Readme.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Declarative tkinter UI with reactive data binding
2+
3+
![Banner](src-docs/img/Banner_no_bg.png)
4+
5+
# Features
6+
- Drag and Drop support (tkDnD)
7+
- Supports async by default (powered by asyncio)
8+
- Two-way data binding
9+
- Flexible layout by design
10+
- Application scrolls automatically
11+
- Simple layout syntax powered by Pug (former Jade)
12+
- Widget parameter support inline python scripting
13+
- ttk themes included
14+
- Lightweight and fast
15+
- Add any custom tkinter widget
16+
17+
![Designer](src-docs/img/designer.GIF)
18+
19+
# Installation
20+
Make sure your python installation is 3.7 or higher.
21+
22+
You need the tk extension **tkDnD** for this framework.
23+
This can be automatically installed via pip argument. Make sure the python directory is writable (e.g. on Mac OSX, Python library are installed to /System/Library, which cannot be modified, even with sudo!).
24+
25+
```pip install layoutx``` (minimal version)
26+
27+
```pip install layoutx[more_widgets, styles]``` (full version)
28+
29+
```python -m layoutx.install_tkdnd``` (install tkdnd)
30+
31+
The command line tool: `lxdesigner` can be used to easily design some forms.
32+
33+
For lxdesigner to function, you need to install addon **more widgets**.
34+
35+
# Addons
36+
Some dependencies of this project have a GPL v3 license. They are excluded into separate addons.
37+
Please note by installing these dependencies, you confirm to the GPL license agreement.
38+
39+
This project itself is licensed under MIT.
40+
41+
## more widgets:
42+
More information see: [ttkwidgets Github](https://github.com/TkinterEP/ttkwidgets/)
43+
44+
- Input
45+
- ComboBox
46+
- TextArea
47+
- Scale
48+
49+
```pip install layoutx[more_widgets]```
50+
51+
## ttk themes:
52+
More information see: [ttkthemes Github](https://github.com/TkinterEP/ttkthemes)
53+
54+
```pip install layoutx[styles]```
55+
56+
# Getting started
57+
58+
``` python
59+
from layoutx import app # Import the app singleton
60+
from layoutx.store import create_store
61+
from layoutx.view import View, ResizeOption
62+
63+
store = create_store({}, { "name": "World" })
64+
65+
class RootView(View):
66+
geometry = "250x50+100+100"
67+
title = "My first app"
68+
resizable = ResizeOption.NONE
69+
template = """\
70+
ScrollFrame
71+
Box(orient="horizontal")
72+
Label Hello
73+
Input(value="{{name}}")
74+
Button(command="{say_my_name}") Say my name!
75+
"""
76+
def say_my_name(self):
77+
print(self.store.state["name"])
78+
79+
if __name__ == "__main__":
80+
app.setup(store=store, rootView=RootView)
81+
app.run()
82+
```
83+
84+
![Getting Started](src-docs/img/index/getting-started.png)
85+
86+
# Documentation
87+
88+
Read the [documentation](https://bomberus.gitlab.io/LayoutX/) for more information.

demo/cat_facts.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from layoutx import app
2+
from layoutx.store import create_store
3+
from layoutx.view import View, ResizeOption
4+
5+
store = create_store({}, {
6+
"facts": [],
7+
"loading": False
8+
})
9+
10+
class LoadFacts(View):
11+
geometry = "800x600+200+200"
12+
title = "FactLoader"
13+
resizable = ResizeOption.BOTH
14+
template = """\
15+
ScrollFrame
16+
Label(if="{loading}") Loading, please wait ...
17+
Button(command="{load_facts}") load facts
18+
Box(for="{fact in facts if fact.type == 'cat'}")
19+
Box(orient="horizontal")
20+
Label(background="{'grey' if fact.deleted else 'green'}") {fact.text}
21+
"""
22+
23+
async def load_facts(self):
24+
self.store.dispatch("SET_VALUE", {
25+
"path": ["loading"],
26+
"value": True
27+
})
28+
import aiohttp
29+
session = aiohttp.ClientSession()
30+
facts_list = []
31+
async with session.get("https://cat-fact.herokuapp.com/facts/random?animal_type=horse&amount=5") as facts:
32+
facts_list += await facts.json()
33+
34+
async with session.get("https://cat-fact.herokuapp.com/facts/random?animal_type=cat&amount=5") as facts:
35+
facts_list += await facts.json()
36+
37+
await session.close()
38+
39+
self.store.dispatch("SET_VALUE", {
40+
"path": ["loading"],
41+
"value": False
42+
})
43+
44+
self.store.dispatch("SET_VALUE", {
45+
"path": ["facts"],
46+
"value": facts_list
47+
})
48+
49+
if __name__ == "__main__":
50+
app.setup(store=store, rootView=LoadFacts)
51+
app.run()

0 commit comments

Comments
 (0)