def spinner(self,*args):
spinner = Spinner(text='Deauth')
box = BoxLayout()
def show_selected_value(spinner, text):
print('Choice : ', text)
if args[1]==True:
self.Status="I am active"
spinner.bind(text=show_selected_value)
box.add_widget(spinner)
runTouchApp(box)
else:
#Here i want to remove my spinner
self.Status="I am inactive"
self.spinner = Spinner(text='Deauth')
self.spinner.parent.remove_widget(self.spinner)
TypeError: 'Spinner' object is not callable
AttributeError: 'NoneType' object has no attribute 'remove_widget'
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# ex.py
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.properties import StringProperty
from kivy.base import runTouchApp
from kivy.uix.spinner import Spinner
from kivy.uix.boxlayout import BoxLayout
class Ex(GridLayout):
Status=StringProperty("I am inactive")
Status1=StringProperty("I am the inactive member of the group")
Status2=StringProperty("I am the inactive member of the group")
def checkActive(self,*args):
if args[1]==True: self.Status="I am active"
else: self.Status="I am inactive"
def checkActive1(self,*args):
if args[1]==True: self.Status1="I am the active member of the group"
else: self.Status1="I am the inactive member of the group"
def checkActive2(self,a,b):
if b==True: self.Status2="I am active member of the group"
else: self.Status2="I am the inactive member of the group"
def checkActive3(self,*args):
if args[1]==False: self.ids['pythonLang'].active=True
def spinner(self,*args):
spinner = Spinner(
# default value shown
text='Deauth',
# available values
values=('Yes', 'No'),
# just for positioning in our example
size_hint=(None, None),
size=(100, 44),
#pos_hint={'center_x': .5, 'center_y': .5})
pos_hint={'right': 1, 'center_y': 0.9})
#pos_hint={'top': 1})
box = BoxLayout()
def show_selected_value(spinner, text):
print('Choice : ', text)
if text=="No":
spinner.parent.remove_widget(spinner)
print('Spin Dis')
if args[1]==True:
#self.spinner= spinner
self.Status="I am active"
spinner.bind(text=show_selected_value)
box.add_widget(spinner)
runTouchApp(box)
flag_done=1
else:
spinner.parent.remove_widget(spinner)
self.Status="I am inactive"
class ExApp(App):
def build(self):
self.title="Checkboxes"
return Ex()
if __name__=='__main__':
ExApp().run()
# ex.kv
<Ex>:
cols: 3
canvas:
Color:
rgb: .2,.2,.2
Rectangle:
pos: self.pos
size: self.size
Label:
text: 'A checkbox'
CheckBox:
#on_active: root.checkActive(*args)
on_active: root.spinner(*args)
Label:
text: root.Status
Label:
text: 'A group checkbox'
CheckBox:
group: 'my_check_group'
on_active: root.checkActive1(*args)
Label:
text: root.Status1
Label:
text: 'A group checkbox'
CheckBox:
group: 'my_check_group'
on_active: root.checkActive2(*args)
Label:
text: root.Status2
Label:
text: 'Python is the best language'
CheckBox:
id: pythonLang
active: True
on_active: root.checkActive3(*args)
Label:
text: 'Right on'
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# ex.py
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.properties import StringProperty
from kivy.base import runTouchApp
from kivy.uix.spinner import Spinner
from kivy.uix.boxlayout import BoxLayout
class Ex(GridLayout):
Status=StringProperty("I am inactive")
Status1=StringProperty("I am the inactive member of the group")
Status2=StringProperty("I am the inactive member of the group")
def __init__(self, **kwargs):
super(Ex, self).__init__(**kwargs)
self.spinner = Spinner(
# default value shown
text='Deauth',
# available values
values=('Yes', 'No'),
# just for positioning in our example
size_hint=(None, None),
size=(100, 44),
#pos_hint={'center_x': .5, 'center_y': .5})
pos_hint={'right': 1, 'center_y': 0.9})
#pos_hint={'top': 1})
self.Status="I am active"
self.ids.box.add_widget(self.spinner)
def checkActive(self,*args):
if args[1]==True: self.Status="I am active"
else: self.Status="I am inactive"
def checkActive1(self,*args):
if args[1]==True: self.Status1="I am the active member of the group"
else: self.Status1="I am the inactive member of the group"
def checkActive2(self,a,b):
if b==True: self.Status2="I am active member of the group"
else: self.Status2="I am the inactive member of the group"
def checkActive3(self,*args):
if args[1]==False: self.ids['pythonLang'].active=True
def toggle_spinner(self, *args):
if not self.spinner.parent:
self.Status="I am active"
self.ids.box.add_widget(self.spinner)
else:
self.spinner.parent.remove_widget(self.spinner)
self.Status="I am inactive"
class ExApp(App):
def build(self):
self.title="Checkboxes"
return Ex()
if __name__=='__main__':
ExApp().run()
# ex.kv
<Ex>:
cols: 3
canvas:
Color:
rgb: .2,.2,.2
Rectangle:
pos: self.pos
size: self.
size
BoxLayout:
id: box
Label:
text: 'A checkbox'
CheckBox:
#on_active: root.checkActive(*args)
on_active: root.toggle_spinner(*args)