Skip to content

the idea is inspired by PySimpleGui , to quickly create simple kivy apps.

License

Notifications You must be signed in to change notification settings

yousuf60/SimpleKivy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleKivy

pip install simplekivy

Do not forget to install:


  • kivy
  • kivymd master branch is recommended

simplekivy is built with kivy to write quickly simple codes

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

]

and you can build simplekivy way using s.build

Examples to test:


from simplekivy import SimpleKivy
s = SimpleKivy(title="test app")
dp = s.metrics.dp

def pressed(instance):
    if text_input.text:
        label.text = text_input.text

background = """
BoxLayout:
    canvas:
        Color:
            rgba: 0, 0, .9, .7
        Rectangle:
            pos: self.pos
            size: self.size

"""

text_input =  s.STextInput(hint_text="type", size_hint=(.5, None), height=dp(60), pos_hint={"center_x":.5})
btn = s.SButton(text = "click", size_hint=(.4, .2), pos_hint={"center_x":.5, "center_y":.5}, on_press=pressed)
label =  s.SLabel(text = "type")

# you don't really need to build here and can just pass the list .. 
# but iam showing you how to get objets using s.build
# so you may need it somewhere else
front = s.build([{"orientation":"vertical"},
                text_input,
                (btn,),
                label            
])

s + [(background,
front
)
]
from simplekivy import SimpleKivy
s = SimpleKivy(title="test app")
screen_manager = s.ScreenManager()

class ScreenI(s.Screen):
    def left(self):
        print("------", self, self.name)
        screen_manager.transition.direction = "right"
        screen_manager.current = screen_manager.previous()

    def right(self):
        print("------", self, self.name)
        screen_manager.transition.direction = "left"
        screen_manager.current = screen_manager.next()

manager = {screen_manager: None}
scr = {}

for i in range(4):
    left = s.SButton(text="left")
    right = s.SButton(text="right")
    screen = ScreenI(name=str(i))
    left.on_press = screen.left
    right.on_press = screen.right
    scr[screen] = [{"orientation":"vertical"},s.SLabel(text=str(i)),[ left, right]]

manager[screen_manager] = scr
s + [
    manager
]

Hints


  • list => BoxLayout
  • tuple => FloatLayout
  • set make_app to False if you do not want to run the kivy App
s = SimpleKivy(make_app=False)
  • to reach the main App object do s.myapp
  • you can pass to s.build a list, tuple, dict, set and kivy lang string
  • the more you understand kivy, the more you enjoy its flexibility

About

the idea is inspired by PySimpleGui , to quickly create simple kivy apps.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published