I would like to put a circular button (buttonBehavior that I changed to make it circle) to the bottom right of a TabbedPanelItem.
So I did like this : Kivy file :
#:kivy 1.0.9
<CircularButton>:
size: (min(self.width,self.height),min(self.width,self.height)) # force circle
canvas:
Color:
rgba: ((1,1,1,1) if self.state == "normal" else (.5,.5,.5,1))
Ellipse:
pos: self.pos
size: self.size
<MainWindow>:
tab_pos: 'left_mid'
size_hint: .5, .5
pos_hint: {'center_x': .5, 'center_y': .5}
do_default_tab: False
TabbedPanelItem:
addIngre: buttonAdd
text: 'All'
CircularButton:
id: buttonAdd
size_hint: .1, .1
pos : 90, 90 #Here it doesn't work
TabbedPanelItem:
text: 'first tab'
Label:
text: 'First tab content area'
TabbedPanelItem:
text: 'tab2'
BoxLayout:
Label:
text: 'Second tab content area'
Button:
text: 'Button that does nothing'
python file :
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.vector import Vector
from kivy.uix.behaviors.button import ButtonBehavior
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ReferenceListProperty,\
ObjectProperty
class CircularButton(ButtonBehavior, Widget):
def __init__(self, **kwargs):
super(CircularButton, self).__init__(**kwargs)
def collide_point(self, x, y):
return Vector(x, y).distance(self.center) <= self.width / 2
def on_release(self):
print("Ok")
class MainWindow(TabbedPanel):
addIngre = ObjectProperty()
pass
class ListApp(App):
def build(self):
return MainWindow()
if __name__ == '__main__':
ListApp().run()
The size_hint works. I believe it gives my widget 10% of the size of the tab, but pos doesn't change the position of my widget. I tried with pos, pos_hint, ... but nothing seems to works, position is not applied to my widget
Do I have to put a position in my widget, and call for this position instead of what I'm doing here?
The TabbedPanel widget manages different widgets in tabs, with a header area for the actual tab buttons and a content area for showing the current tab content.
TabbedPanelItem:
addIngre: buttonAdd
text: 'All'
FloatLayout:
CircularButton:
id: buttonAdd
size_hint: .1, .1
# pos: root.center
# pos_hint: {'x': 0.9, 'y': 0.9}
pos_hint: {'x': 0.3, 'y': 0.5}