Kivy (framework)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Kivy
DeveloperKivy organization
Initial release1 February 2011; 15 years ago (2011-02-01)[1]
Stable release
2.3.1 / 26 December 2024; 18 months ago (2024-12-26)[2]
Repositorygithub.com/kivy/kivy
Written inPython, Cython
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemCross-platform
    TypeApplication framework
    LicenseMIT (Free software)
    Websitekivy.org

    Kivy is a free and open source Python framework for developing mobile apps and other multitouch application software with a natural user interface (NUI). It is distributed under the terms of the MIT License, and can run on Android, iOS, Linux, macOS, and Windows.

    Kivy is the main framework developed by the Kivy organization,[3] alongside Python for Android,[4] Kivy for iOS,[5] and several other libraries meant to be used on all platforms. In 2012, Kivy got a $5000 grant from the Python Software Foundation for porting it to Python 3.3.[6] Kivy also supports the Raspberry Pi which was funded through Bountysource.[7]

    The framework contains all the elements for building an application such as:

    Kivy is an evolution of the PyMT project.[9]

    Code example

    [edit | edit source]

    Here is an example of the Hello world program with just one button:

    from kivy.app import App
    from kivy.uix.button import Button
    
    class TestApp(App):
        def build(self):
            return Button(text="Hello World")
    
    TestApp().run()
    

    Kv language

    [edit | edit source]

    The Kv language is a language dedicated to describing user interface and interactions in Kivy framework. As with other user interface markup languages, it is possible to easily create a whole UI and attach interaction. For example, to create a Loading dialog that includes a file browser, and a Cancel / Load button, one could first create the base widget in Python and then construct the UI in Kv.

    In main.py:

    class LoadDialog(FloatLayout):
        def load(self, filename): pass
        def cancel(self): pass
    

    And in the associated Kv:

    #:kivy 1.11.1
    
    <LoadDialog>:
        BoxLayout:
            size: root.size
            pos: root.pos
            orientation: "vertical"
    
            FileChooserListView:
                id: filechooser
    
            BoxLayout:
                size_hint_y: None
                height: 30
    
                Button:
                    text: "Cancel"
                    on_release: root.cancel()
    
                Button:
                    text: "Load"
                    on_release: root.load(filechooser.path, filechooser.selection)
    

    Alternatively, the layout (here, Box Layout) and the buttons can be loaded directly in the main.py file.

    [edit | edit source]

    Google Summer of Code

    [edit | edit source]

    Kivy participated in Google Summer of Code under the Python Software Foundation.

    • Kivy in GSoC'2014.[10]
    • Kivy in GSoC'2015.[11]
    • Kivy in GSoC'2016.[12]
    • Kivy in GSoC'2017.[13]

    See also

    [edit | edit source]

    Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

    References

    [edit | edit source]
    1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]