2015-02-01 02:16:40 +00:00
|
|
|
'''
|
|
|
|
Circle Example
|
|
|
|
==============
|
|
|
|
|
2015-02-02 01:09:20 +00:00
|
|
|
This example exercises circle (ellipse) drawing. You should see sliders at the
|
|
|
|
top of the screen with the Kivy logo below it. The sliders control the
|
|
|
|
angle start and stop and the height and width scales. There is a button
|
2015-02-12 04:00:30 +00:00
|
|
|
to reset the sliders. The logo used for the circle's background image is
|
|
|
|
from the kivy/data directory. The entire example is coded in the
|
2015-02-01 02:16:40 +00:00
|
|
|
kv language description.
|
|
|
|
'''
|
2013-09-27 16:24:21 +00:00
|
|
|
|
|
|
|
from kivy.app import App
|
|
|
|
from kivy.lang import Builder
|
|
|
|
|
|
|
|
kv = '''
|
2013-09-28 16:52:43 +00:00
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
2013-09-27 16:24:21 +00:00
|
|
|
BoxLayout:
|
2013-09-28 16:52:43 +00:00
|
|
|
size_hint_y: None
|
|
|
|
height: sp(100)
|
2013-09-27 16:24:21 +00:00
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Slider:
|
|
|
|
id: e1
|
|
|
|
min: -360.
|
|
|
|
max: 360.
|
|
|
|
Label:
|
2013-09-28 16:52:43 +00:00
|
|
|
text: 'angle_start = {}'.format(e1.value)
|
2013-09-27 16:24:21 +00:00
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Slider:
|
|
|
|
id: e2
|
|
|
|
min: -360.
|
|
|
|
max: 360.
|
|
|
|
value: 360
|
|
|
|
Label:
|
2013-09-28 16:52:43 +00:00
|
|
|
text: 'angle_end = {}'.format(e2.value)
|
2013-09-27 16:24:21 +00:00
|
|
|
|
2013-09-28 16:52:43 +00:00
|
|
|
BoxLayout:
|
|
|
|
size_hint_y: None
|
|
|
|
height: sp(100)
|
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Slider:
|
|
|
|
id: wm
|
|
|
|
min: 0
|
|
|
|
max: 2
|
|
|
|
value: 1
|
|
|
|
Label:
|
|
|
|
text: 'Width mult. = {}'.format(wm.value)
|
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Slider:
|
|
|
|
id: hm
|
|
|
|
min: 0
|
|
|
|
max: 2
|
|
|
|
value: 1
|
|
|
|
Label:
|
|
|
|
text: 'Height mult. = {}'.format(hm.value)
|
|
|
|
Button:
|
|
|
|
text: 'Reset ratios'
|
|
|
|
on_press: wm.value = 1; hm.value = 1
|
2015-02-02 01:09:20 +00:00
|
|
|
|
2013-09-28 16:52:43 +00:00
|
|
|
FloatLayout:
|
2013-09-27 16:24:21 +00:00
|
|
|
canvas:
|
|
|
|
Color:
|
|
|
|
rgb: 1, 1, 1
|
|
|
|
Ellipse:
|
|
|
|
pos: 100, 100
|
2013-09-28 16:52:43 +00:00
|
|
|
size: 200 * wm.value, 201 * hm.value
|
2013-09-27 16:24:21 +00:00
|
|
|
source: 'data/logo/kivy-icon-512.png'
|
|
|
|
angle_start: e1.value
|
|
|
|
angle_end: e2.value
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
2015-02-02 01:09:20 +00:00
|
|
|
|
2013-09-27 16:24:21 +00:00
|
|
|
class CircleApp(App):
|
|
|
|
def build(self):
|
|
|
|
return Builder.load_string(kv)
|
|
|
|
|
2016-12-17 07:50:52 +00:00
|
|
|
|
2013-09-27 16:24:21 +00:00
|
|
|
CircleApp().run()
|