the idea is inspired by PySimpleGui , to quickly create simple kivy apps
Project description
SimpleKivy
pip install simplekivy
Perfect versions:
- kivy==2.2.1
- python >= 3.7
simplekivy is built on kivy to write simple code faster
you can write kvlang and creat your own classes and widgets as kivy is flexible
the widgets are added only once via simpleKivyObject + [
#kv_widgets
]
Examples to test:
from simplekivy import SimpleKivy
s = SimpleKivy(title="test")
dp = s.metrics.dp
s + [
(# floatlayout <=> ()
{"size_hint": (1, None)},#<=> add the floatlayout kwargs
s.Label(text="ffljwfe", pos_hint={"center_x":.5, "center_y":.5}),
{"height": dp(200)}, #kwargs as you want will be added
),
[ #boxlayout <=> []
{"size_hint": (1, .5)},
s.Button(text="gdddg"),
s.Button(text="gdgdd")
],
]
from simplekivy import SimpleKivy
s = SimpleKivy(title="test app")
dp = s.metrics.dp
inp1 = s.TextInput(size_hint=(.5, None), height=dp(50), pos_hint={"center_x":.5})
inp1_button = s.Button(text="click", on_press=lambda x:print(inp1.text),
size_hint=(.5, None), height=dp(50),
pos_hint={"center_x":.5})
s + [
(#floatlayout
{"size_hint":(1, 1)},
[#boxlayout
{"orientation":"vertical", "size_hint":(1, None), "height":dp(200),
"spacing":"60dp","pos_hint":{"center_y":.5}},
inp1,
inp1_button])
]
from simplekivy import SimpleKivy
def on_enter(instance):
print(instance.text)
s = SimpleKivy(title="test app")
ainput = s.TextInput(multiline=False, size_hint=(1, None),
height="50dp", pos_hint={"center_x":.5, "center_y":.7})
ainput.bind(on_text_validate=on_enter)
s + [
[{"orientation":"vertical", "size_hint":(1, .4)},
s.Label(text="hello world", halign="center"),
s.Label(text="testo")],
({"size_hint":(.4, .6), "pos_hint":{"center_x":.5}},
ainput
)
]
you can also add kvlang string directly instead of using
s.lang.Builder
or kivy.lang.Builder
from simplekivy import SimpleKivy
s = SimpleKivy(title="test app", make_app=True)
def on_enter(instance):
print(instance.text)
def btn_pressed():
print(ainput.text)
#add a new method to app
s.myapp.btn_pressed = btn_pressed
KV_BTN = """
Button:
text: "press me"
size_hint:.4, .2
pos_hint: {"center_x": .5, "center_y": .5}
on_press:app.btn_pressed()
"""
ainput = s.TextInput(hint_text="type anything", multiline=False, size_hint=(1, None),
height="50dp", pos_hint={"center_x":.5, "center_y":.7})
ainput.bind(on_text_validate=on_enter)
s + [
[{"orientation":"vertical", "size_hint":(1, .2)},
s.Label(text="hello world", halign="center"),
s.Label(text="testo")],
({"size_hint":(.4, .4), "pos_hint":{"center_x":.5}},
ainput
),
({"size_hint": (1, .4)},
KV_BTN),
]
Hints
- list => BoxLayout
- tuple => FloatLayout
- set
make_apptoFalseif you do not want to run the kivy App
s = SimpleKivy(make_app=False)
- to reach the main App object do
s.myapp - the more you understand kivy, the more you enjoy its flexibility
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simplekivy-0.0.3.tar.gz.
File metadata
- Download URL: simplekivy-0.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2157fdc4d0959d83a9b8467d52a565dbd9587606cd916b5db7e8c7d71d696eba
|
|
| MD5 |
806223f137fca2ce4fff867d017321eb
|
|
| BLAKE2b-256 |
6a33c10a50f5fda1832393f078748fdaabd0e37b201f5eb78648ef345b07d915
|
File details
Details for the file simplekivy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: simplekivy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0a939291515f3cd28328b600c29b4c7966ba94acebc31bdd61b5feadef72b94
|
|
| MD5 |
491946dc5a24056220353cb0a8c0fb9e
|
|
| BLAKE2b-256 |
00e7e74aca6390cb04a9eef7c49e7e571e6e5e19f76f60b0df547b2ca3a81e2f
|