Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kivy language cumbersomeness and rationale behind it

Kivy has this kv language to define the UI , the definition file can become quite complex , There is a kv designer package on github which automates the generation of kv files but is quite buggy and unreliable. So the question is why does kivy want the programmer to manually write those UI definitions like even hardcode the positions and dimensions of UI widgets. Most other libraries like QT, VB etc have a UI designer as the core feature but Kivy did not start with it and expects programmers to hardcode it , I find it pretty cumbersome although I feel I am missing something. Or is it that it is only I who find a steep learning curve for kv language and I don't know about some tools which help in writing kv files.

like image 527
stackit Avatar asked May 04 '15 05:05

stackit


People also ask

Which language is used in KIVY?

The KV language, sometimes called kvlang or the kivy language, allows you to create your widget tree in a declarative way and to bind widget properties to each other or to callbacks in a natural manner. It allows for very fast prototypes and agile changes to your UI.

What is KIVY?

The Kivy is defined as a python library that is available as a free, open-source library used for building the cross-platform applications that include Windows, Linux, iOS, Android and other platforms and the look and feel of each application will be different from each other.

What is Self in KIVY?

self refers to current widget instance Rectangle. Rectangle is not a widget, it is a canvas instruction. self does refer to the current widget, which in your example is the PongGame . Follow this answer to receive notifications.


1 Answers

If you're asking why Kivy wasn't designed around a GUI interface builder:

In their design philosophy doc, they hint at the reason:

Kivy is focused. You can write a simple application with a few lines of code. Kivy programs are created using the Python programming language, which is incredibly versatile and powerful, yet easy to use. In addition, we created our own description language, the Kivy Language, for creating sophisticated user interfaces. This language allows you to set up, connect and arrange your application elements quickly. We feel that allowing you to focus on the essence of your application is more important than forcing you to fiddle with compiler settings. We took that burden off your shoulders.

This implies pretty strongly that they believe that the way to make GUI applications less cumbersome is a text-driven declarative design like the kv language, not a WYSIWYG interface builder. So, that's why they did things this way.

But why would they think that? Well, here things get subjective.

You obviously don't agree with them. Apple doesn't either. Maybe Microsoft doesn't. But it's certainly the trend everyone else is following. People have moved from using graphical HTML designers to using a combination of declarative and procedural design directly in HTML and JS code. Macromedia created Flex to allow people to create Flash apps without having to use Flash Designer. The various cross-platform GUI frameworks (Gtk+, wx, Tk, JUCE, etc.) either don't have an interface builder, or have it as an optional "stepchild" tool; the only exception is Qt, which didn't get a tightly integrated designer until 4.0.

Take a look at how much work goes into Xcode and Visual Studio, and all the extra complex things Apple and Microsoft have to build to enable them (remember, both companies essentially took over and remade a programming language just to work with their interface builders, because the existing mainstream languages didn't fit). Kivy may be a commercially-funded project, but they don't have unlimited resources, and presumably they thought the effort they would have to spend on a doing something like Cocoa and Xcode could be better spent somewhere else.


For the side question on why they use static pixel-based layouts, like VB or wx, instead of relative layouts, like Cocoa or Qt… Well, first, it's not requiring that, it's giving you the option. There are advantages to both, but when you're trying to make it easier to design apps that look good on 320x480 screens at a time when everyone is noticing how badly HTML and other tools designed to be "scalable to any size" actually scaled to those sizes, I can see the advantages of pixel-perfect layout winning out. (Notice that HTML/CSS similarly gives you both options. And the earliest websites to make mobile pages took advantage of pixel-layout CSS, but they've gradually evolved as people worked out how to make "scalable" and "small" work together, and as mobile screens have become more variable.)

like image 118
abarnert Avatar answered Sep 23 '22 02:09

abarnert