本文整理匯總了Python中kivy.uix.checkbox.CheckBox.value方法的典型用法代碼示例。如果您正苦於以下問題:Python CheckBox.value方法的具體用法?Python CheckBox.value怎麽用?Python CheckBox.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類kivy.uix.checkbox.CheckBox
的用法示例。
在下文中一共展示了CheckBox.value方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from kivy.uix.checkbox import CheckBox [as 別名]
# 或者: from kivy.uix.checkbox.CheckBox import value [as 別名]
def __init__(self, title, choices, key, callback):
Factory.Popup.__init__(self)
if type(choices) is list:
choices = dict(map(lambda x: (x,x), choices))
layout = self.ids.choices
layout.bind(minimum_height=layout.setter('height'))
for k, v in sorted(choices.items()):
l = Label(text=v)
l.height = '48dp'
l.size_hint_x = 4
cb = CheckBox(group='choices')
cb.value = k
cb.height = '48dp'
cb.size_hint_x = 1
def f(cb, x):
if x: self.value = cb.value
cb.bind(active=f)
if k == key:
cb.active = True
layout.add_widget(l)
layout.add_widget(cb)
layout.add_widget(Widget(size_hint_y=1))
self.callback = callback
self.title = title
self.value = key
示例2: __init__
# 需要導入模塊: from kivy.uix.checkbox import CheckBox [as 別名]
# 或者: from kivy.uix.checkbox.CheckBox import value [as 別名]
def __init__(self, title, choices, key, callback, keep_choice_order=False):
Factory.Popup.__init__(self)
print(choices, type(choices))
if keep_choice_order:
orig_index = {choice: i for (i, choice) in enumerate(choices)}
sort_key = lambda x: orig_index[x[0]]
else:
sort_key = lambda x: x
if type(choices) is list:
choices = dict(map(lambda x: (x,x), choices))
layout = self.ids.choices
layout.bind(minimum_height=layout.setter('height'))
for k, v in sorted(choices.items(), key=sort_key):
l = Label(text=v)
l.height = '48dp'
l.size_hint_x = 4
cb = CheckBox(group='choices')
cb.value = k
cb.height = '48dp'
cb.size_hint_x = 1
def f(cb, x):
if x: self.value = cb.value
cb.bind(active=f)
if k == key:
cb.active = True
layout.add_widget(l)
layout.add_widget(cb)
layout.add_widget(Widget(size_hint_y=1))
self.callback = callback
self.title = title
self.value = key
示例3: __init__
# 需要導入模塊: from kivy.uix.checkbox import CheckBox [as 別名]
# 或者: from kivy.uix.checkbox.CheckBox import value [as 別名]
def __init__(self, title, choices, key, callback):
Factory.Popup.__init__(self)
for k, v in choices.items():
l = Label(text=v)
l.height = '48dp'
cb = CheckBox(group='choices')
cb.value = k
cb.height = '48dp'
def f(cb, x):
if x: self.value = cb.value
cb.bind(active=f)
if k == key:
cb.active = True
self.ids.choices.add_widget(l)
self.ids.choices.add_widget(cb)
self.ids.choices.add_widget(Widget(size_hint_y=1))
self.callback = callback
self.title = title
self.value = key