Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
As we have discussed earlier that how to work with images and now in this we will gonna be learn how to use the images and create a button with them. In this article we will learn how can we use the image as button and how to add functionality and styling on that image.
To learn about it you must be aware about some properties, that are –
1) Background image of the button used for the default graphical representation when the button is pressed.
2) background_down is a StringProperty .
1) Background image of the button used for the default graphical representation when the button is not pressed.
2) background_normal is also a StringProperty .
1) Background image of the button used for the default graphical representation when the button is disabled and not pressed.
2) background_disabled_normal is also a StringProperty .
1) Now its only sufficient to understand that string property means they only take values in string that means like background_down: “normal.png” like this.
2) On click on the image it looks same like a simple button (as we uses it in a button).
Image used in this this article are:
Basic Approach : -> import kivy -> import kivy App -> import button -> set minimum version(optional) -> Extend the class : -> create an image a button -> Do styling -> Arrange call back if needed -> Add and return a button -> Run an instance of the class
Code to implement the styling and arranging a callback to the button –
- Add image button using .kv file in kivy
- Disable Kivy Button
- Change button Color in Kivy
- Disable kivy button using .kv file
- Python | Button Action in Kivy
- Python | Toggle button in kivy using .kv file
- Text Input box with a verification button in kivy
- Python - Rounding button corners in kivy
- Change the size and position of button in Kivy
- Text Input box with a verification button in kivy (using .kv file)
- Python - Rounding button corners in kivy using .kv file
- Python - Change button color in kivy using .kv file
- Floating Action type button in kivy - Python
- Animated Floating Action Button in kivy - Python
- Circular (Oval like) button using canvas in kivy (using .kv file)
- Python - Change kivy button size and position using kv file
- Python | Add image widget in Kivy
- Python | Adding image in Kivy using .kv file
- wxPython - Add Image in Button
- wxPython - Image on button in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.