Editable spinner - python

I need to make something like a spinner or dropdown list but with the ability to input the value manually when there is no right value on the list.
I'm trying to find some properties of spinner but no one seems to fit. Is there any posibility in kv language?

Here's a basic implementation using DropDown widget.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
kv = """
<CustomDropdown>:
size_hint_y: None
pos_hint: {"top": 1}
height: 56.0
orientation: "horizontal"
TextInput:
id: txt_input
size_hint_x: 0.5
Button:
id: show_drop
size_hint_x: 0.2
text: "drop"
on_release: root.show_dropdown()
Button:
id: submit_btn
size_hint_x: 0.3
text: "Submit"
on_press: root.validate_txt()
"""
class CustomDropdown(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.dropdown = DropDown()
self.fakeValues = ["First", "Second", "Third"]
for val in self.fakeValues:
btn = Button(text=val, size_hint=[0.5, None])
btn.height = 56.0
btn.bind(on_press=self.change_value)
self.dropdown.add_widget(btn)
def change_value(self, *args):
self.ids.txt_input.text = args[0].text
self.hide_dropdown()
def add_options(self, *args):
btn = Button(text=args[0], size_hint=[0.5, None])
btn.height = 56.0
btn.bind(on_press=self.change_value)
self.dropdown.add_widget(btn)
def validate_txt(self, *args):
curText = self.ids.txt_input.text
if ((curText in self.fakeValues) or (curText == None) or (curText == "")):
return
self.fakeValues.append(curText)
self.add_options(curText)
self.hide_dropdown()
def hide_dropdown(self):
self.dropdown.dismiss()
def show_dropdown(self, *args):
if self.dropdown.parent:
self.hide_dropdown()
else:
self.dropdown.open(self.ids.txt_input)
class TestApp(App):
def build(self):
Builder.load_string(kv)
return CustomDropdown()
TestApp().run()
Before doing anything:
Showing DropDown:
Typing some custom words and submitting it:
Showing DropDown again:

Related

Kivy - Can't change .text with id

I am trying to change the text of a label using an id, I tried it with stringProperty, with objectProperty without any properties. There has to be something I am missing in my code because it simply does not work whatever I try and any help would be greatly appreciated.
This bit of code is a simple screen with 2 buttons, one for going to the other screen and one for changing the label
from kivy.app import *
from kivy.uix.button import *
from kivy.graphics import *
from kivy.uix.widget import *
from kivy.uix.label import *
from kivy.uix.floatlayout import *
from kivy.uix.boxlayout import *
from kivy.uix.relativelayout import *
from kivy.uix.scrollview import ScrollView
from kivy.properties import ListProperty, StringProperty,ObjectProperty
from kivy.uix.screenmanager import ScreenManager,Screen
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout
class WindowManager(ScreenManager):
pass
class Name(FloatLayout):
def __init__(self, **kwargs):
super(Name, self).__init__(**kwargs)
def changeName(self):
print(self.ids)
self.name = self.ids.nameOfSong.text
print(self.name)
self.ids.nameOfSong.text = 'name'
self.name = self.ids.nameOfSong.text
print(self.name)
class MainWindow(Screen):
def __init__(self, **kwargs):
super(MainWindow, self).__init__(**kwargs)
self.pos = (0, 0)
self.size = (1,1)
self.z = Name()
self.add_widget(self.z)
def swap(self):
Name().changeName()
class SecondWindow(Screen,BoxLayout):
def __init__(self, **kwargs):
super(SecondWindow, self).__init__(**kwargs)
class langApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(MainWindow(name='main'))
sm.add_widget(SecondWindow(name='second'))
return sm
Builder.load_file("kiv.kv")
if __name__ == '__main__':
langApp().run()
My kiv.kv file, most of it is not connected to the problem (I think)
#:kivy 1.11.1
WindowManager:
MainWindow:
SecondWindow:
<MainWindow>:
name: "main"
FloatLayout:
pos: 0,0
size: root.width,root.height
Button:
on_release:
root.manager.transition.direction = 'left'
app.root.current = "second"
text: 'Stop'
pos_hint: {'x':.45,'y':.1}
size_hint: .1,.1
Button:
on_press: root.swap()
text: 'Next'
pos_hint: {'x':.65,'y':.1}
size_hint: .1,.1
<SecondWindow>:
name: "second"
FloatLayout:
pos: 0,0
size: root.width,root.height
Button:
on_release:
root.manager.transition.direction = 'right'
app.root.current = "main"
text: 'Stop'
pos_hint: {'x':.45,'y':.1}
size_hint: .1,.1
<Name>:
Label:
text: nameOfSong
font_size: 20
size_hint: None, None
pos_hint: {'x': 0.435, 'y': 0.25}
A few problems with your code:
First, your code as posted dos not run. The line in your kv:
text: nameOfSong
is illegal.
Second, the code:
def swap(self):
Name().changeName()
is creating a new instance of Name and calling changeName() on that new instance. However, that new instance is not the one that is displayed in your GUI.
To fix that, you just need to call changeName() on the instance of Name that is in your GUI. Conveniently, you have saved a reference to the correct instance with the line:
self.z = Name()
So, you can change the swap() method to use that instance of Name:
def swap(self):
self.z.changeName()
The other problem is that the changeName() method tries to use a non-existent id nameOfSong. To fix that (and to make your posted code runnable), just change the <Name> rule in your kv to define that id:
<Name>:
Label:
id: nameOfSong
text: 'Some Name'
font_size: 20
size_hint: None, None
pos_hint: {'x': 0.435, 'y': 0.25}
On an unrelated note, your code is building the App GUI twice. The line:
Builder.load_file("kiv.kv")
is building the GUI from the lines:
WindowManager:
MainWindow:
SecondWindow:
and your python code is building it again here:
def build(self):
sm = ScreenManager()
sm.add_widget(MainWindow(name='main'))
sm.add_widget(SecondWindow(name='second'))
return sm
You can delete those three lines from your kv file.

Passing Kivy Widget to another class

I am building a dynamic user interface using Python and Kivy. Because I need to add and remove widgets dynamically I want to use a separate class to handle adding and removing widgets from a GridLayout. I called this class LayoutManager.
The GridLayout is defined in my kv-File (id: "config_box_layout"). Inside my root widget class in my python code I am referencing the GridLayout via id. This is working properly. This reference is passed to the LayoutManager in the constructor. I tried passing it via ObjectProperty or GridLayout.
The problem is that I always end up with this kind of error if I try to remove widgets from the Layout:
'kivy.properties.ObjectProperty' object has no attribute 'remove_widget'
If I try to remove a widget in the save-method inside my Tab class using config_box_layout.remove_widget(some newly created Label) it's working properly.
I think the problem is that Kivy and all the kv-widgets are weakly-referenced and handling those references over to other classes seem to be not the intended use case.
I try to seperate classes to avoid doing all the coding stuff in one big fat main Layout class.
Looking forward to any help! :)
main.py
import kivy
from util.layoutManager import LayoutManager
from kivy.app import App
kivy.require('1.11.1')
from kivy.uix.label import Label
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.properties import ObjectProperty
from kivy.uix.popup import Popup
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from functools import partial
class ChooseDirectoryDialog(FloatLayout):
add = ObjectProperty(None)
cancel = ObjectProperty(None)
save = ObjectProperty(None)
class Tab(TabbedPanel):
config_add_src = ObjectProperty()
ingest_layout = ObjectProperty()
configManager = ConfigManager()
config_box_layout = ObjectProperty()
layoutManager = LayoutManager(config_box_layout)
def add_src(self):
content = ChooseDirectoryDialog(cancel=self.cancel, save=self.save)
self._popup = Popup(title="Add Source", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def cancel(self):
self._popup.dismiss()
def delete_source(self, description, widget):
self.configManager.delete_source(description)
self.remove_source_from_ui(description)
def remove_source_from_ui(self, description):
self.layoutManager.remove_configuration(description)
def save(self, srcpath, destpath, description):
desc_label = Label(text=description)
desc_label.size_hint_y = None
desc_label.height = 30
self.config_box_layout.add_widget(desc_label)
srcpath_label = Label(text=srcpath)
srcpath_label.size_hint_y = None
srcpath_label.height = 30
self.config_box_layout.add_widget(srcpath_label)
destpath_label = Label(text=destpath)
destpath_label.size_hint_y = None
destpath_label.height = 30
self.config_box_layout.add_widget(destpath_label)
deleteButton = Button(text="Quelle löschen")
deleteButton.size_hint_y = None
deleteButton.height = 30
deleteButton.bind(on_press=partial(self.delete_source, description))
self.config_box_layout.add_widget(deleteButton)
self.layoutManager.add_configuration(description,
desc_label, srcpath_label, destpath_label, deleteButton)
self.configManager.add_source(description, srcpath, destpath)
self._popup.dismiss()
def copyToDestination(self, srcpath, destpath):
pass
class AutoIngest(App):
def build(self):
return Tab()
if __name__ == '__main__':
#Builder.load_file('autoingest.kv')
AutoIngest().run()
autoingest.kv
#:kivy 1.11.1
<Tab>:
do_default_tab: False
config_add_button: add_button
config_box_layout: config_box
TabbedPanelItem:
text: 'Konfiguration'
TabbedPanel:
tab_width: 200
do_default_tab: False
TabbedPanelItem:
text: 'Quellen verwalten'
StackLayout:
orientation: "lr-tb"
padding: 10
Button:
size_hint: .2, .1
id: add_button
text: 'Quelle hinzufügen'
on_press: root.add_src()
GridLayout:
id: config_box
cols: 4
Label:
size_hint_y: None
height: 30
text: "Bezeichnung"
Label:
size_hint_y: None
height: 30
text: "Quell-Pfad"
Label:
size_hint_y: None
height: 30
text: "Ziel-Pfad"
Label:
size_hint_y: None
height: 30
text: "Aktionen"
<ChooseDirectoryDialog>:
text_input: text_input
BoxLayout:
size: root.size
pos: root.pos
orientation: "vertical"
Label:
size_hint_y: None
height: 30
text: "Bezeichnung"
TextInput:
id: text_input
size_hint_y: None
height: 30
multiline: False
Label:
size_hint_y: None
height: 30
text: "Quellverzeichnis auswählen"
FileChooserListView:
id: source_chooser
Label:
size_hint_y: None
height: 30
text: "Zielverzeichnis auswählen"
FileChooserListView:
id: destination_chooser
BoxLayout:
size_hint_y: None
height: 30
Button:
text: "Cancel"
on_release: root.cancel()
Button:
text: "Add"
on_release: root.save(source_chooser.path, destination_chooser.path, text_input.text)
layoutManager.py
from kivy.uix.gridlayout import GridLayout
from kivy.properties import ObjectProperty
class LayoutManager:
#I alrey tried to pass the GridLayout itself. This didn't work either.
def __init__(self, configlayout: ObjectProperty):
self.configurations = {}
self.configlayout = configlayout
def remove_configuration(self, description):
widgets = self.configurations.get(description)
for x in widgets:
self.configlayout.remove_widget(x)
def add_configuration(self, description, *widgets):
self.configurations[description] = {'widgets': widgets}
I believe the problem is that the Tab instance ids have not been setup when your lines:
config_box_layout = ObjectProperty()
layoutManager = LayoutManager(config_box_layout)
are executed, so config_box_layout is not yet set.
You can force the creation of the LayoutManager to delay until the ids are created using kivy.clock in the build() method of the App:
class AutoIngest(App):
def build(self):
Clock.schedule_once(self.setup_layoutManager)
return Tab()
def setup_layoutManager(self, dt):
self.root.layoutManager = LayoutManager(self.root.config_box_layout)
Also, the line:
layoutManager = LayoutManager(config_box_layout)
can be removed from the Tab class.
Once that is working you will discover issues in your remove_configuration() method of LayoutManager.

Pass a list to/from Kivy textinput dialog

I have a list to display to the user but I want to break each section to a separate textinput as it will make more sense that way. I then need to be able to capture those changes and update my variable.
I need to get the variables to display correctly tlmanualreg being backgroundManualReg[0] and on closeit() store the changes back to a list.
EDIT: Updated with bare bones popup project to test variable exchanging.
from kivy.properties import StringProperty
from os.path import join, dirname
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.app import App
import json
Builder.load_string("""
<-MyPopup#Popup>:
tlpos:tlpos
tlmanualreg:tlmanualreg
cols: 1
GridLayout:
cols:3
Label:
text: "Location"
Label:
text: "Dist from Center (mm)"
Label:
text: "Corners of sheet (for manual-align)"
Label:
text: "Top-Left:"
TextInput:
id: tlpos
text: root.backgroundTLPOS
TextInput:
id: tlmanualreg
text: root.backgroundTLManualReg
Button:
size_hint_y:.1
text: 'Update Variables'
on_press: root.closeit()
""")
class ScreensApp(App):
def build(self):
content = MyPopup()
_popup = Popup(content=content, auto_dismiss=False)
_popup.open()
class MyPopup(Popup):
backgroundManualReg = [[551, 218], [3168, 319], [519, 1617], [3190, 1589]]
backgroundTLPOS = StringProperty("[0, 0]")
backgroundTLManualReg = StringProperty("[1,1],[2,2]")
def __init__(self, **kwargs):
super(MyPopup, self).__init__(**kwargs)
self.ids.tlmanualreg.text = str([1, 1])
self.backgroundTLManualReg = str(self.backgroundManualReg[0])
def closeit(self):
self.backgroundTLPOS = self.tlpos.text
print("backgroundTLPOS: ", self.backgroundTLPOS)
print("backgroundTLManualReg: ", self.ids.tlmanualreg.text)
print("backgroundManualReg: ", self.backgroundManualReg)
if __name__ == '__main__':
ScreensApp().run()
In the following example, we are:
Using dictionary. The key of the dictionary is use as Kivy widget's id and also as a reference to update the values.
Dynamically adding widgets as per item (key, value) in the dictionary
Retrieving data using for child in reversed(self.container.children) and isinstance(child, TextInput)
Example
main.py
from kivy.properties import StringProperty, DictProperty
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
import ast
Builder.load_string("""
<HeaderCell#Label>
text_size: self.size
halign: "left"
valign: "middle"
canvas.before:
Color:
rgba: 1, 0.502, 0, 1
Rectangle:
pos: self.pos
size: self.size
<MyPopup>:
title: 'My Popup'
container: container
GridLayout:
cols: 1
GridLayout:
cols: 3
size_hint_y: 0.1
HeaderCell:
text: "Location"
HeaderCell:
text: "Dist from Center (mm)"
HeaderCell:
text: "Corners of sheet (for manual-align)"
GridLayout:
id: container
cols:3
Button:
size_hint_y:.1
text: 'Update Variables'
on_press: root.closeit()
""")
class ScreensApp(App):
def build(self):
_popup = MyPopup(auto_dismiss=False)
_popup.open()
class MyPopup(Popup):
backgroundTLPOS = StringProperty("[0, 0]")
bgManualRegDict = DictProperty({'Top-Left': [551, 218], 'Top-Right': [3168, 319],
'Bottom-Left': [519, 1617], 'Bottom-Right': [3190, 1589]})
def __init__(self, **kwargs):
super(MyPopup, self).__init__(**kwargs)
self.populate_rows()
def populate_rows(self):
for key, value in self.bgManualRegDict.items():
location = Label(text="{}:".format(key), valign="middle")
location.bind(size=location.setter('text_size'))
bgTLpos = TextInput(text="{}".format(self.backgroundTLPOS))
bgTLmanualReg = TextInput(id="{}".format(key), text="{}".format(value))
self.container.add_widget(location)
self.container.add_widget(bgTLpos)
self.container.add_widget(bgTLmanualReg)
def closeit(self):
print("\ncloseit:")
for child in reversed(self.container.children):
if isinstance(child, TextInput):
if child.id in self.bgManualRegDict.keys():
print("\tid={0}, text={1}".format(child.id, child.text))
self.bgManualRegDict[child.id] = ast.literal_eval(child.text)
print("\n\tself.bgManualRegDict=", self.bgManualRegDict)
if __name__ == '__main__':
ScreensApp().run()
Output

How to get Id and Text value of a kivy button as string?

I have an app with multiple buttons and I need to get id and text value of the button as string when it is pressed. The grabbed Ids and Text valus of the button will then be passed to another function for further processing. For simplicity I wrote this sample programme.
# main.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
########################################################################
class KVMyHBoxLayout(BoxLayout):
pass
########################################################################
class ExampleApp(App):
def Pressbtn(self, *args):
print'Pressed button'
#----------------------------------------------------------------------
def build(self):
return KVMyHBoxLayout()
#----------------------------------------------------------------------
if __name__ == "__main__":
app = ExampleApp()
app.run()
kv file
<MyButton#Button>:
color: .8,.9,0,1
font_size: 32
<KVMyHBoxLayout>:
orientation: 'vertical'
MyButton:
id:"idBtn1"
text: "Btn1"
background_color: 1,0,0,1
on_press:app.Pressbtn()
MyButton:
id:"idBtn2"
text: "Btn2"
background_color: 0,1,0,1
on_press:app.Pressbtn()
Label:
text: "ID"
background_color: 0,0,1,1
Label:
text: "Text"
background_color: 1,0,1,1
When a button is pressed its corresponding values of id and text will be shown in the ID and Text labels. Currently the above code only print Pressed button when button is pressed. I want to know how to get id and text value of button pythonically.
First, you must pass the button instance explicitly to the method when it is called from the kv:
on_press: app.Pressbtn(self)
You can then use the instance reference to modify the button or see its attributes, you do not need the id. If you want to get the id, you can only do it using the ids dictionary of the button parent.
An example based on your code:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
kv_file = '''
<MyButton#Button>:
color: .8,.9,0,1
font_size: 32
<KVMyHBoxLayout>:
orientation: 'vertical'
MyButton:
id:"idBtn1"
text: "Btn1"
background_color: 1,0,0,1
on_press:app.Pressbtn(self)
MyButton:
id:"idBtn2"
text: "Btn2"
background_color: 0,1,0,1
on_press:app.Pressbtn(self)
Label:
id: lobj
text: "Object"
background_color: 1,0,1,1
Label:
id: lid
text: "ID"
background_color: 0,0,1,1
Label:
id: ltext
text: "Text"
background_color: 1,0,1,1
'''
class KVMyHBoxLayout(BoxLayout):
pass
class ExampleApp(App):
def Pressbtn(self, instance):
instance.parent.ids.lobj.text = str(instance)
instance.parent.ids.ltext.text = instance.text
instance.parent.ids.lid.text= self.get_id(instance)
def get_id(self, instance):
for id, widget in instance.parent.ids.items():
if widget.__self__ == instance:
return id
def build(self):
Builder.load_string(kv_file)
return KVMyHBoxLayout()
if __name__ == "__main__":
app = ExampleApp()
app.run()
Output:
Edit:
If you define the widget (button) in the .py file you do not need to pass the instance to the function, it is passed automatically as argument:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
class FirstScreen(Screen):
def __init__(self,**kwargs):
super(FirstScreen, self).__init__(**kwargs)
layout=BoxLayout(orientation="vertical",size_hint_y= None)
layout.bind(minimum_height=layout.setter('height'))
for i in range(50):
btn = Button(text="Button"+str(i),
id=str(i),
size_hint=(None, None),
on_press=self.Press_auth) #<<<<<<<<<<<<<<<<
layout.add_widget(btn)
root = ScrollView()
root.add_widget(layout)
self.add_widget(root)
def Press_auth(self,instance):
print(str(instance))
class TestScreenManager(ScreenManager):
def __init__(self, **kwargs):
super(TestScreenManager, self).__init__(**kwargs)
self.add_widget(FirstScreen())
class ExampleApp(App):
def build(self):
return TestScreenManager()
def main():
app = ExampleApp()
app.run()
if __name__ == '__main__':
main()
You can use a callback function something along these lines. In your KV file:
ToggleButton:
text: 'Label'
id: halftimebutton
on_state: root.callback(self)
And then in your .py file you can do this:
def callback_halftime_state(self, instance):
if instance.state == 'down':
self.halftime == True
else:
self.halftime == False
This is of course showing the instance.state - but it could be any attribute of the button that Kivy exposes; instance.text, instance.id, etc.
example to get button text on button click :
class MainApp(MDApp):
def build(self):
VB = BoxLayout(orientation='vertical', padding=50,spacing="10")
Atbtn = Button(text="AT (Automata Theory)", font_size="25sp")
Atbtn.bind(on_press=self.callback)
Pybtn = Button(text="Python", font_size="25sp")
Pybtn.bind(on_press=self.callback)
VB.add_widget(Atbtn)
VB.add_widget(Pybtn)
return VB
def callback(self, instance):
print(instance.text)

I try to put spinner object on tab panel in kivy but not working, help me

So this is the basic code of my tab item.
import kivy
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.gridlayout import GridLayout
Builder.load_string("""
<Test>:
size_hint: .8, .5
pos_hint: {'center_x': .4, 'center_y': .3}
do_default_tab: False
TabbedPanelItem:
text: 'Tab 1'
Label:
text: 'Syntax'
TabbedPanelItem:
text: 'Changeover'
TabbedPanelItem:
text: 'Map'
""")
class Test(TabbedPanel):
pass
class TabbedPanelApp(App):
def build(self):
return Test()
if __name__ == '__main__':
TabbedPanelApp().run()
and i want to insert spinner on Tab 1, how to make it work? this is my spinner code.
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.factory import Factory
from kivy.properties import ListProperty, ObjectProperty
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
import kivy
from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
class MultiSelectSpinner(Button):
dropdown = ObjectProperty(None)
values = ListProperty([])
selected_values = ListProperty([])
def __init__(self, **kwargs):
self.bind(dropdown=self.update_dropdown)
self.bind(values=self.update_dropdown)
super(MultiSelectSpinner, self).__init__(**kwargs)
self.bind(on_release=self.toggle_dropdown)
def toggle_dropdown(self, *args):
if self.dropdown.parent:
self.dropdown.dismiss()
else:
self.dropdown.open(self)
def update_dropdown(self, *args):
if not self.dropdown:
self.dropdown = DropDown()
values = self.values
if values:
if self.dropdown.children:
self.dropdown.clear_widgets()
for value in values:
b = Factory.MultiSelectOption(text=value)
b.bind(state=self.select_value)
self.dropdown.add_widget(b)
def select_value(self, instance, value):
if value == 'down':
if instance.text not in self.selected_values:
self.selected_values.append(instance.text)
else:
if instance.text in self.selected_values:
self.selected_values.remove(instance.text)
def on_selected_values(self, instance, value):
if value:
self.text = ', '.join(value)
else:
self.text = ''
kv = '''
BoxLayout:
orientation: 'vertical'
size_hint: .7, .6
pos_hint: {'center_x': .3, 'center_y': .7}
do_default_tab: False
BoxLayout:
Label:
text: 'Food Type'
MultiSelectSpinner:
values: 'Fried Chicken', 'Burger'
<MultiSelectOption#ToggleButton>:
size_hint: 8, None
height: '40dp'
'''
runTouchApp(Builder.load_string(kv))
i need abit pointer please
i try to merge the code but not working.
glad if someone can help
i think its best if you create a custom TabbledPanelItem. and then implement that spinner in it.forgive my indentation
class Mod(TabbedPanelItem):
one = ObjectProperty(None)
def __init__(self,**kwargs):
super(Mod,self).__init__(**kwargs)
def on_touch_down(self, touch):
if self.state == 'down':
# dispatch to children, not to self
for child in self.children:
child.dispatch('on_touch_down', touch)
return
else:
super(Mod, self).on_touch_down(touch)
def on_release(self, *largs):
if self.parent:
self.parent.tabbed_panel.switch_to(self)
print(self.parent.children)
lola = MultiSelectSpinner()
lola.toggle_dropdown()
else:
# tab removed before we could switch to it. Switch back to
# previous tab
self.panel.switch_to(self.panel.current_tab)

Categories

Resources