Introduction to Advanced Python

Kivy or Kiwi?!

Dec 2024
@1995parham
python-logo

Kivy or Kiwi

Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

Do you know JavaFX?

Kivy Installation

Hello Kivy


  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 Design Language

Kivy provides a design language specifically geared towards easy and scalable GUI Design. The language makes it simple to separate the interface design from the application logic, adhering to the separation of concerns principle.

KV Design Language (cont'd)

There are two ways to load Kv code into your application:

  • By name convention
  • 
        MyApp -> my.kv
        
  • Builder
  • 
        Builder.load_file('path/to/file.kv')
        

Events

  • Clock Events
  • Input Events
  • Class Events

Layouts

Layouts are containers used to arrange widgets in a particular manner.

  • Anchor Layout: Widgets can be anchored to the top, bottom, left, right or center.
  • Box Layout: Widgets are arranged sequentially, in either a vertical or a horizontal orientation.
  • GridLayout: Widgets are arranged in a grid defined by the rows and cols properties.
Fork me on GitHub