2011-12-30 23:12:14 +00:00
|
|
|
'''
|
|
|
|
Bubble
|
2012-01-09 00:17:52 +00:00
|
|
|
======
|
2011-12-30 23:12:14 +00:00
|
|
|
|
2012-01-02 12:52:15 +00:00
|
|
|
Test of the widget Bubble.
|
2011-12-30 23:12:14 +00:00
|
|
|
'''
|
|
|
|
|
2012-01-04 01:14:44 +00:00
|
|
|
from kivy.app import App
|
2011-12-30 23:12:14 +00:00
|
|
|
from kivy.uix.floatlayout import FloatLayout
|
2012-01-04 01:14:44 +00:00
|
|
|
from kivy.uix.button import Button
|
|
|
|
from kivy.lang import Builder
|
2012-01-09 00:17:52 +00:00
|
|
|
from kivy.uix.bubble import Bubble
|
2011-12-30 23:12:14 +00:00
|
|
|
|
2012-01-02 13:58:45 +00:00
|
|
|
Builder.load_string('''
|
|
|
|
<cut_copy_paste>
|
2012-01-09 00:17:52 +00:00
|
|
|
size_hint: (None, None)
|
2013-06-30 15:56:35 +00:00
|
|
|
size: (160, 120)
|
2012-01-09 00:17:52 +00:00
|
|
|
pos_hint: {'center_x': .5, 'y': .6}
|
2012-01-11 23:47:46 +00:00
|
|
|
BubbleButton:
|
2012-01-09 00:17:52 +00:00
|
|
|
text: 'Cut'
|
2012-01-11 23:47:46 +00:00
|
|
|
BubbleButton:
|
2012-01-09 00:17:52 +00:00
|
|
|
text: 'Copy'
|
2012-01-11 23:47:46 +00:00
|
|
|
BubbleButton:
|
2012-01-09 00:17:52 +00:00
|
|
|
text: 'Paste'
|
2012-01-02 13:58:45 +00:00
|
|
|
''')
|
|
|
|
|
2012-01-04 01:14:44 +00:00
|
|
|
|
2012-01-09 00:17:52 +00:00
|
|
|
class cut_copy_paste(Bubble):
|
2012-01-02 13:58:45 +00:00
|
|
|
pass
|
|
|
|
|
2011-12-30 23:12:14 +00:00
|
|
|
|
|
|
|
class BubbleShowcase(FloatLayout):
|
2012-01-04 01:14:44 +00:00
|
|
|
|
2011-12-30 23:12:14 +00:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
super(BubbleShowcase, self).__init__(**kwargs)
|
2012-01-09 00:17:52 +00:00
|
|
|
self.but_bubble = Button(text='Press to show bubble')
|
|
|
|
self.but_bubble.bind(on_release=self.show_bubble)
|
2011-12-30 23:12:14 +00:00
|
|
|
self.add_widget(self.but_bubble)
|
|
|
|
|
|
|
|
def show_bubble(self, *l):
|
2012-01-09 00:17:52 +00:00
|
|
|
if not hasattr(self, 'bubb'):
|
|
|
|
self.bubb = bubb = cut_copy_paste()
|
|
|
|
self.add_widget(bubb)
|
|
|
|
else:
|
|
|
|
values = ('left_top', 'left_mid', 'left_bottom', 'top_left',
|
|
|
|
'top_mid', 'top_right', 'right_top', 'right_mid',
|
|
|
|
'right_bottom', 'bottom_left', 'bottom_mid', 'bottom_right')
|
|
|
|
index = values.index(self.bubb.arrow_pos)
|
|
|
|
self.bubb.arrow_pos = values[(index + 1) % len(values)]
|
2011-12-30 23:12:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestBubbleApp(App):
|
2012-01-04 01:14:44 +00:00
|
|
|
|
2011-12-30 23:12:14 +00:00
|
|
|
def build(self):
|
|
|
|
return BubbleShowcase()
|
|
|
|
|
2012-07-29 19:43:01 +00:00
|
|
|
if __name__ == '__main__':
|
2011-12-30 23:12:14 +00:00
|
|
|
TestBubbleApp().run()
|