When I use the RoundedRectangle
in Kivy, the rounded corners are jaggy (not smooth).
Is it possible to create a smooth rounded button (with transparent corners)?
Here is my test code:
import os
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.anchorlayout import AnchorLayout
class MyLayout(AnchorLayout):
pass
Builder.load_string('''
<RoundedButton@Button>:
size_hint: (None, None)
size: (200, 50)
background_color: 0,0,0,0 # alpha=0
canvas.before:
Color:
rgba: (.4,.4,.4,1) if self.state=='normal' else (0,.7,.7,1) # visual feedback of press
RoundedRectangle:
pos: self.pos
size: self.size
radius: [self.size[1]//2]
<MyLayout>
anchor_x: 'center'
anchor_y: 'center'
RoundedButton:
text: 'Rounded Button'
''')
class TestApp(App):
def build(self):
return MyLayout()
TestApp().run()
Note: because the configuration os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'
you might need Windows OS with DirectX to reproduce this code exactly. See Kivy issue #6276.