Hej
I like to customize the On/Off Switch in kivy. For a Button I know how to do it. The kv code looks like this:
Button:
background_normal: 'gfx/offButton.png'
background_down: 'gfx/onButton.png'
Now I whant to know it for the Switch widget. Any Ideas?
The switch does not have properties to control this. Maybe it should, but it also has more behaviour than just on/off since you can drag the slider.
If you just want an active/inactive choice, you could use a CheckBox (which does have background image properties).
Related
In my program I am using QtTabWidget in which the user can dynamically add tabs as per their needs. I think that the norm of an "Add Tab (+)" Button is now defined by the way we see it in our web browsers like chrome. Which is why I would like to replicate such a button in my program. Please find an example image of what I want my button to look like.
I have found a few people asking this question but not a solid solution to it yet. An example solution is "https://stackoverflow.com/questions/22616446/add-plus-button-to-tabwidget-pyqt4" however the main problem with this is that the new tab button is a corner widget which appears at the top right hand corner of my screen (see image below). Although I would prefer it to be dynamically positioned on the tab bar where it is just adjacent to the final tab that is open.
I am trying to use kivy as the graphical system and yet i dont know how to put inside a button and a label at the same time where label shows text and button closes popup also there is one import ant thing here it must be a function that can have editable title and contents and buttob(text) and can be launched like: self.popup(text1, text1, text3) Does anyone know how do it?
Kivy popup contents: What do you want ? Nobody can answer this !!! Give a precise question (here are some propositions for your next SO post).
I am trying to use kivy as the graphical system: How to use kivy app as a graphical system ?
and yet i dont know how to put inside a button and a label at the same time where label shows text and button closes popup
Kivy: how to add a widget (Label/Button) to an app ?
Kivy: how to change Label text ?
Kivy: how to bind a function on a button click ?
Kivy: How to close a popup ?
also there is one import ant thing here: .
it must be a function that can have editable title and contents and buttob(text):
I think you should check out what theses terms are: POO, Inheritance, attribute, method.
I recently discovered that I can remove and add widgets in Kivy without having to create new ones by simply referring to their ids, for instance:
self.remove_widget(self.ids['my_button']) # Removes the widget
self.add_widget(self.ids['my_button']) # Adds the previously removed widget
This is perfect for my program, as I will often need to add and remove the same buttons.
However, Kivy will render everything that I write in the accompanying kv file, and I only would like certain buttons to appear at certain preset instances. I was wondering if there was a way to specify in a kv file for kivy NOT to render a widget at start-up, and instead wait for instructions to do so.
I think that the above approach is faster than constantly creating and destroying new buttons and more elegant than storing the buttons as an ObjectProperty.
Thanks in advance!
You can hide the Widget, if its parent is FloatLayout or RelativeLayout, by adding the following lines to its kv rule:
size_hint: 0, 0
pos: -1, -1
opacity: 0
The opacity set to zero makes it invisible, and the size_hint and pos keep it from responding to touch events. So the widget is actually rendered, but with zero opacity and zero size.
Note that just setting size to zeros will not make all widgets invisible. A Label or Button will still draw its text.
Now you can remove the widget. If you want it to show you will need to adjust the opacity, size_hint, and pos.
I've beeing coding applications for years using C# and Delphi. And one of the greatest things of those languages, in my opinion, was how easy it was to code the interface - you could grab the buttons, make the rectangles and etc, all using the mouse, dragging the squares.
Now I'm interested in Kivy, using Python. Can I construct the desktop interface just like Delphi, using the mouse and making the layout easily, or is the interface made only through coding?
Thanks for the patience, guys.
If you want to use kivy I suggest that you learn Kv Language which is a simple language to design the UI for kivy.
.kv file example:
<MyWidget>:
label_widget: label_widget
Button:
text: 'Add Button'
on_press: root.add_widget(label_widget)
Button:
text: 'Remove Button'
on_press: root.remove_widget(label_widget)
Label:
id: label_widget
text: 'widget'
There is however a Kivy Designer which you can use to design the UI but it is still at alpha stage and not perfect yet.
WARNING: This project is at an unstable alpha stage and is not yet
suitable for general use. Contributions are welcome.
Kivy Designer is Kivy's tool for designing graphical user interfaces
(GUIs) from Kivy Widgets. You can compose and customize widgets, and
test them. It is completely written in Python using Kivy.
So if it doesn't do what you want, you can create a simple UI and have a look at the generated code so you get an idea of how the UI is written in python.
I want to be able to open the bubble with a button click.
I am kind of new to kivy.
Here's the code in the kivy file:
Button:
bubble:bubble.__self__
text:"Home"
on_release:self.show_bubble
Bubble:
id:bubble
size_hint: (None, None)
size: (150, 50)
pos_hint: {'x': 1, 'y': 1.7}
arrow_pos: 'bottom_mid'
orientation: 'horizontal'
BubbleButton:
text: "This is"
BubbleButton:
text: "a"
BubbleButton:
text: "Bubble"
Could anyone help?
Thanks.
You should follow the example shown here:
https://kivy.org/docs/api-kivy.uix.bubble.html
i.e. put the Bubble in a separate FloatLayout (for example) instead of inside the triggering Button
I have worked in KIVY for mobile-based application development. But let me tell you its quite a pain. If you just want to make interactive python programs that are not mobile based I think you should start with the Tkinter module.
KIVY is really ugly. I suggest porting to JAVA for mobile application development simply because it was born to do that.
We have a long way till everyone starts using python for mobile apps.