Kivy tongue bulkiness and rationale behind it

Kivy has this kv languageto define a user interface, the definition file can get quite complex. There is a kv design package on github that automates the generation of kv files, but is rather buggy and unreliable. So the question is why kivy wants a programmer to manually write down UI definitions like hardcode, positions and sizes of the UI widget. Most other libraries like QT, VB, etc. have a UI designer as their main function, but Kivy did not start with it and expects programmers to hardcode it, I find it quite cumbersome, although I feel that something is missing. Or is it just that I find a steep learning curve for kv language and I am unaware of some of the tools that help write kv files.

+3


source to share


2 answers


If you are asking why Kivy was not designed around a GUI builder:

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

Kiwi is focused. You can write a simple application with a few lines of code. Kivy programs are written 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, to create complex user interfaces. This language allows you to quickly configure, connect and organize the elements of your application. We believe that you need to focus on the essence of your application, which is more important than having you fiddling with compiler settings. We have taken this burden off your shoulders.

This suggests that they believe that the way to make GUI applications less cumbersome is to declare text based on text as a language kv

rather than a WYSIWYG interface builder. So why did they do that.

But why do they think so? Well, this is where things get subjective.



You obviously disagree with them. Apple too. Maybe Microsoft doesn't. But this is definitely a trend that everyone else is following. People have moved from using HTML graphic designers to using a combination of declarative and procedural design directly in HTML and JS code. Macromedia created Flex so that users can create Flash applications without using Flash Designer. Various cross-platform GUIs (Gtk +, wx, Tk, JUCE, etc.) either do not have an interface constructor, or have one as an additional "stepchild" tool; the only exception is Qt, which didn't get a tightly integrated designer until 4.0.

Check out how much work in Xcode and Visual Studio, and all the extra complex stuff Apple and Microsoft have to build to enable them (remember that both companies essentially took over and rewrote the programming language to work with their front-end builders. as existing major languages ​​are not suitable). Kiwi may be a commercially funded project, but they don't have unlimited resources, and apparently they thought they'd have to spend to make something like Cocoa, while Xcode is better off somewhere else.


For the question of why they use static pixel layouts like VB or wx instead of relative layouts like Cocoa or Qt ... Well, first of all, it doesn't require it to give you that option. There are benefits to both, but when you're trying to make it easier to develop applications that look good on 320x480 screens at a time when everyone notices how poorly HTML and other tools designed to "scale to any size" actually scale to those sizes, I I can see the benefits of pixel perfect layout. (Note that HTML / CSS similarly gives you both. And the earliest websites that made mobile pages used CSS with a pixelated layout, but they gradually evolved as people developed ways to "scale"and "small" interactions, and as mobile screens have become more variable.)

+3


source


as well as hard code, positions and sizes of the UI widget.

You don't need to hardcode the positions and sizes of the UI widget. While you can do this, this is usually not a good idea for obvious reasons that you are probably thinking about.



You are probably missing the role of layout classes that impose ordering on child widgets. For example, a BoxLayout stacks all of its children in a horizontal or vertical line so that together they fill their area with relative sizes defined by their size_hint properties. With this and other layouts, you don't need to specify the size of the grips, and everything will automatically adapt to changes in the window size or the sizes of individual widgets.

As for why we use kv so much, abarnert's answer and discussion illuminates the philosophy and the underlying reasons very well. However, we are not against the use of charting tools, but none of the main developers have invested in them. Kivy Designer is an early stage in the project to do such a thing as it is a popular request, but development was slow due to the small amount of contributions. Also, I suppose that creating a GUI constructor is probably more difficult than parsing a simple language like kv. This year we have a GSoC project that will hopefully lead it towards a more usable state that can generate more interest.

+2


source







All Articles