|
Hello
First, it seems there are quite fundamental things about kivy that you missed, which means either you didn't read the documentation, or we did a pretty bad job at explaining them, but i'm quite impressed that you could go through 3 projects without understanding them.
That's a weird thing to start on, it's really a convention, we have two events here, it's up to you to decide on which to bind, and if you change your mind, pretty easy to change.
Kv lang is inspired by yaml and by qml, sure, it's not exactly the same, but it's not completly out of nowhere.
I'm pretty sure that's explained in the documenation, but i'll restate it here:
app simplest of them all, always refer to your App instance.
self always refer to the innermost widget you are into, look lines up until you find a widget class name, that's the widget you are talking about
root always refer to the outermost widget you are into, look lines up until you find one that is not indented at all, that's the widget you are talking about
- Layouts manage the position of all their direct children, if you nest something in a widget, it's not affected anymore by the layout.
Doing what you are asking for here can be easy:
FloatLayout:
Button:
id: button
size_hint: .5, .5
pos_hint: {'center': (.5, .5)}
Image:
source: 'images/image-loading.gif'
size: button.size
pos: button.pos
# you can add another label at the top of it, if the image hides the button's text
Label:
text: button.text
pos: button.pos
size: button.size
But you could also do your own ImageButton class, and use it as many time as you want
<ImageButton@ButtonBehavior+Image>:
# is an Image with a button behavior, has on_press/release, etc
text: ''
# add a label at the top to display text atop the image
Label:
text: root.text
size: root.size
pos: root.pos
text_size: root.size
I pretty often refactor a specific widget into a rule, it's not very different from taking out python code and make it into a function, cut, paste, unindent as much as needed, add a "header" (here new widget name), and the parameters, then use it at the previous place… Not sure if your editor is getting in the way somehow, or if you have a more specific issue you want to share.
- see #4 plus
- Layouts use size_hint and pos_hint to manage children's size/pos automatically, so pos/size won't have any effect in a layout's children unless size_hint/pos_hint allows them to.
- Other widgets don't use size_hint/pos_hint, so only pos/size will have an effect
see the answer to #3, or give more details, in my experience Image is simple, but very flexible.
Can't answer here, because i don't use that, but that looks like an issue with scrolling, which delay touches, that's an issue with kivy i'm willing to concede, our default values for scroll_timeout and scroll_distance are far from perfect, but you can tweak them, and improve things a lot.
You might want to use a specific widget if you have large amount of text to display, although TextInput does allow scrolling, it does so differently from ScrollView, i would advice (if it's only for display), using a RecycleView.
ListView is deprecated for a good reason, it's developpment didn't go the way we intended, it's API doesn't allow for good performances, as you noted, it's now replaced by RecycleView, we strongly advise everybody to switch. RecycleView itself works a bit differently, but you just need to pass a list of dicts containing your data, and the widget that will display them, to your layout. I know there is only one example in the documentation, but it's a good starting point, and some experimentation should clarify things. If not, questions are always welcome.
Kivy focuses on its own set of widgets, but sometime you want a native look, not a common UI on all platform, and it's fine, for these things, plyer offer some answers, and one of them is a FileChooser that uses the native platform one. You might want to have a look.
Criticism is always welcome, maybe our concepts are flawed or maybe we need to better explain them. But i personally build kivy apps at work at quite a decent speed, and i see others able to do the same, what takes is time is usually bugs that have to be fixed or worked around, not the general logic of the framework. |