本文整理汇总了Python中kivy.uix.togglebutton.ToggleButton方法的典型用法代码示例。如果您正苦于以下问题:Python togglebutton.ToggleButton方法的具体用法?Python togglebutton.ToggleButton怎么用?Python togglebutton.ToggleButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.togglebutton
的用法示例。
在下文中一共展示了togglebutton.ToggleButton方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_filter
# 需要导入模块: from kivy.uix import togglebutton [as 别名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 别名]
def draw_filter(self):
"""Create a list of toggle buttons to allow user to show which buses
should be shown on the screen.
"""
# If we've got no filter then we need to set it up:
if self.filters is None:
# Clear the previous filter
self.ids.bx_filter.clear_widgets()
# Get the list of unique bus routes and apply a natural sort.
routes = sorted(set([x["route"] for x in self.buses]),
key=natural_sort_key)
# Create a toggle button for each route and set it as enabled
# for now.
for route in routes:
tb = ToggleButton(text=route, state="down")
tb.bind(state=self.toggled)
self.ids.bx_filter.add_widget(tb)
# Run the "toggled" method now as this updates which buses are shown.
self.toggled(None, None)
示例2: _heading
# 需要导入模块: from kivy.uix import togglebutton [as 别名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 别名]
def _heading(game, view):
heading = Label(font_name='DroidSans-Regular.ttf', font_size=18,
color=HEADING_COLOR, markup=False)
heading.pos = (ANIM_TOGGLE_SIZE, 500 - PADDING)
heading.size = (960 - ANIM_TOGGLE_SIZE * 2, HEIGHT)
view.add_widget(heading)
def state_change(btn, state):
game.set_animooted(state == 'down')
anim_toggle = ToggleButton(background_normal='media/chkbox.png',
background_down='media/chkbox_a.png',
border=(0, 0, 0, 20), font_size=15,
text='Display Animations', state='down',
color=HEADING_COLOR, markup=False)
anim_toggle.pos = (965 - ANIM_TOGGLE_SIZE, 510 - PADDING)
anim_toggle.size = (ANIM_TOGGLE_SIZE, 30)
anim_toggle.bind(state=state_change)
view.add_widget(anim_toggle)
game._heading = heading
game.update_heading()
示例3: draw_filter
# 需要导入模块: from kivy.uix import togglebutton [as 别名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 别名]
def draw_filter(self):
"""Create a list of toggle buttons to allow user to show which buses
should be shown on the screen.
"""
# If we've got no filter then we need to set it up:
if self.filters is None:
# Clear the previous filter
self.ids.bx_filter.clear_widgets()
# Get the list of unique bus routes and apply a natural sort.
routes = sorted(set([x["route"] for x in self.buses]),
key=natural_sort_key)
# Create a toggle button for each route and set it as enabled
# for now.
for route in routes:
route_found=False
for child in self.ids.bx_filter.children:
if (route == child.text):
route_found = True
if (route_found == False):
tb = ToggleButton(text=route, state="down")
tb.bind(state=self.toggled)
self.ids.bx_filter.add_widget(tb)
# Run the "toggled" method now as this updates which buses are shown.
self.toggled(None, None)
示例4: _create_popup
# 需要导入模块: from kivy.uix import togglebutton [as 别名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 别名]
def _create_popup(self, instance):
# create the popup
content = BoxLayout(orientation='vertical', spacing='5dp')
popup_width = min(0.95 * Window.width, dp(500))
self.popup = popup = Popup(
content=content, title=self.title, size_hint=(None, None),
size=(popup_width, '400dp'))
popup.height = len(self.options) * dp(55) + dp(150)
# add all the options
content.add_widget(Widget(size_hint_y=None, height=1))
uid = str(self.uid)
for option in self.options:
state = 'down' if option == self.value else 'normal'
btn = ToggleButton(text=option, state=state, group=uid)
btn.bind(on_release=self._set_option)
content.add_widget(btn)
# finally, add a cancel button to return on the previous panel
content.add_widget(SettingSpacer())
btn = Button(text='Cancel', size_hint_y=None, height=dp(50))
btn.bind(on_release=popup.dismiss)
content.add_widget(btn)
# and open the popup !
popup.open()
示例5: _draw_form
# 需要导入模块: from kivy.uix import togglebutton [as 别名]
# 或者: from kivy.uix.togglebutton import ToggleButton [as 别名]
def _draw_form(self):
"""
Encompasses the drawing of a form with a textual label onto the card.
"""
inner_layout = BoxLayout(orientation="vertical")
label_layout = BoxLayout(orientation="vertical", size_hint=(1, 0.2))
self.form_label = Label(
text=self.text, font_size=self.font_size, markup=True
)
self.form_label.color = list(self.text_color)
self.form_label.valign = "top"
self.form_label.halign = "left"
label_layout.add_widget(self.form_label)
form_layout = BoxLayout(orientation="vertical")
form_layout.padding = 10
filler = None
if self.form == Inputs.TEXTBOX:
self.textbox = TextInput(text="", multiline=False)
self.textbox.font_size = self.font_size
form_layout.size_hint = (1, 0.2)
form_layout.add_widget(self.textbox)
filler = BoxLayout(orientation="vertical", size_hint=(1, 0.6))
elif self.form == Inputs.TEXTAREA:
self.textarea = TextInput(text="")
self.textarea.font_size = self.font_size
form_layout.add_widget(self.textarea)
elif self.form == Inputs.MULTICHOICE:
self.multichoice = []
for item in self.options:
button = ToggleButton(text=item)
button.font_size = self.font_size
form_layout.add_widget(button)
self.multichoice.append(button)
elif self.form == Inputs.SELECT:
self.select = []
for item in self.options:
button = ToggleButton(text=item, group=self.title)
button.font_size = self.font_size
form_layout.add_widget(button)
self.select.append(button)
elif self.form == Inputs.SLIDER:
min_val = self.options[0]
max_val = self.options[1]
if len(self.options) == 3:
step = self.options[2]
else:
step = 1
self.slider = Slider(
value_track=True, min=min_val, max=max_val, step=step
)
self.slider_label = Label(text="0", font_size=64)
self.slider.bind(value=self._slider_change)
form_layout.add_widget(self.slider)
form_layout.add_widget(self.slider_label)
inner_layout.add_widget(label_layout)
inner_layout.add_widget(form_layout)
if filler:
inner_layout.add_widget(filler)
self.layout.add_widget(inner_layout)