Skip to main content Svelte Highlight v7.21.1

KV language preview

1. A simple rule

a rule header, a canvas block, and a Python expression
horizon-dark
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)
atom-one-dark
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)
github-dark
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)
dracula
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)
nord
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)
github
#:kivy 2.0
#:import utils app.utils

<MyWidget@BoxLayout>:
  orientation: "vertical"
  canvas.before:
    Color:
      rgba: 1, 1, 1, 1

  Label:
    text: "Hello, {}".format(self.name)
    on_press: root.handle_press(self)

2. App references

root, self, and app in property expressions
horizon-dark
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)
atom-one-dark
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)
github-dark
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)
dracula
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)
nord
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)
github
<RootWidget>:
  size_hint: None, None
  on_touch_down: app.handle_touch(self, root)

3. Nested children

widget instantiation without an explicit class name
horizon-dark
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"
atom-one-dark
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"
github-dark
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"
dracula
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"
nord
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"
github
BoxLayout:
  orientation: "horizontal"

  Button:
    text: "OK"

  Button:
    text: "Cancel"