question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How about this feature for kivy lang?

See original GitHub issue

I am new to kivy lang, and I am fascinated by it. I was trying to use kivy to build a tree layout UI, where each node in the tree should be a text input, and the tree may be dynamic. So I am wondering if the kivy lang can be made more powerful by adding conditions and for loops. Here is an imaginary kivy file with the new power on:

RootWidget:

    # a conditional example
    Button if root.need_button:
           text: 'press me'
    else Label:
           text: 'feedback'

   # a more complex one
   Button if root.need_confirm:
          text: 'Confirm'
   else Label if root.need_label:
          text: 'Nice Job!'
   else Widget:
          # empty widget here...

   # here is a for loop example
   Rectangle for data in root.data:
         pos: data.pos
         size: data.size

As I am new to kivy lang, clearly my idea could be totally out of place. Just ask around to see if this proposal is possible at all or plausible at all.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dessantcommented, Apr 23, 2016

We would suggest making a pr if you’d like to see if your proposal is viable, but we don’t plan to work on this in its current form.

0reactions
langitcommented, Apr 20, 2016

@KeyWeeUsr that switch_with is a nice option, however it might not be as flexible. A cooked up example of interest may look like this:

Root:
   Button if root.status == 0:
      text: "place an order" 
      on_press: lambda: root.order_status = 1
   else TextInput if root.status == 1:
      on_key: lambda key: root.status = 2 if key.name == 'enter' else 1
   else Button if root.status == 2:
       text: "confirm order"
       on_press: lambda: root.status = 3
   else Label:
       text: "order confirmed"

As for efficiency, an idea is that kv could be translated into python equivalent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kivy Language — Kivy 2.1.0 documentation
The Kivy language is a language dedicated to describing user interface and interactions. You could compare this language to Qt's QML (http://qt.nokia.com), ...
Read more >
How to use the kivy.lang.Builder function in Kivy - Snyk
properties import StringProperty, ObjectProperty, NumericProperty, ListProperty, BooleanProperty,\ OptionProperty, Clock from kivy.
Read more >
Kivy language function call on button press using screens
I am trying to call a function within a screen from a button press and I want to facilitate this with a kv...
Read more >
Kivy Part 4 - Using Python and the Kivy Language
We already have a basic Kivy app in Python, but in Kivy we can also use a special Kivy language which is used...
Read more >
Kivy Documentation - Read the Docs
Learn: The basics of programming with the Kivy language. ... versionadded:: to mark the version in which the feature was added.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found