I learnt that in Qt we do have some ways to make a QpushButton with :
- Shadow effect
- making it Flat by making setFlat properties to True .
- chaning the cursor of a different type if someone hovers over it like pushButton_18.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
I am looking to make Buttons behavior similar in kivy as well . Is it possible ? I learnt that we can change background Image changed to a Image with rounded shape Changing the background color of a Button in Kivy
but this is not that satisfying as the button still looks very normal . There s no shadow affect . Even when we click on the corners outside the button it is treated s if button is clicked .
I have gone through documentation of Kivy Button as well as Label and tried to change the behavior and look of a button . Can someone advice on how to make a button look better We can try to have :
- Shadowing affect
- Animation affect in background
- Rounded edges etc .
- Can we put animated gif Images as background for animation (I did try that but it wasnt animated anymore )
Below is a code which i just created for exploring more into buttons in Kivy :
__author__ = 'pbatra'
#Good info about background
#https://stackoverflow.com/questions/20181250/changing-the-background-color-of-a-button- in-kivy/20181407#20181407
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.properties import ObjectProperty
from kivy.uix.image import Image
from kivy.graphics import Color
gui = '''
<MenuScreen>:
canvas.before:
BorderImage:
# BorderImage behaves like the CSS BorderImage
border: 10, 10, 10, 10
texture: self.background_image.texture
pos: self.pos
size: self.size
GridLayout:
size_hint: .1, .1
pos_hint: {'center_x': .5, 'center_y': .5}
rows: 1
Button:
text: 'Play'
font_size: 20
font_name: 'DroidSans'
bold: True
italic: True
height: 10
background_color: (0.5, 0.7, 0.5, 0.9)
#Read more about them from documentation
background_normal: './images/orange.png'
background_down: './images/green.png'
border: 30,30,30,30
color: (1, .3, .8, .5)
on_press: self.text = 'Oh yeah'
'''
class MenuScreen(Screen):
background_image = ObjectProperty(
Image(
source='../Examples/examples/widgets/sequenced_images/data/images/button_white_animated.zip',
anim_delay=.5))
Builder.load_string(gui)
pass
# Create the screen manager
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
class MyJB(App):
def build(self):
return sm
if __name__ == '__main__':
MyJB().run()