本文整理汇总了Python中kivy.uix.spinner.Spinner.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Spinner.bind方法的具体用法?Python Spinner.bind怎么用?Python Spinner.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.spinner.Spinner
的用法示例。
在下文中一共展示了Spinner.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Options
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
class Options(GridLayout):
def __init__(self, **kwargs):
super(Options, self).__init__(**kwargs)
self.rows = 1
self.spinner = Spinner(text='Easy',values=('Easy', 'Medium', 'Hard'))
self.add_widget(self.spinner)
self.spinner.bind(text=self.show_selected_value)
startBtn = Button(text = "start")
self.add_widget(startBtn)
startBtn.bind(on_release=self.start)
stopBtn = Button(text = "stop")
self.add_widget(stopBtn)
stopBtn.bind(on_press=self.stop)
def stop(self,*args):
App.get_running_app().root.children[1].stop()
def start(self,ins,*args):
app = App.get_running_app().root.children[1]
if ins.text == "continue":
app.continue_move()
elif ins.text == "start":
app.start()
ins.text = "continue"
def show_selected_value(self, ins,text):
if text == 'Easy':
pass
elif text == 'Medium':
pass
elif text == 'Hard':
pass
示例2: DrpDwnList
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
class DrpDwnList(BoxLayout):
def __init__(self, caption, values, action=None, s_text='..select..',
**kwargs):
self.values = values
self.action = action
super(DrpDwnList, self).__init__(padding=0, spacing=0,
size_hint=(1,None),
orientation='vertical', **kwargs)
lbl = Label(
# height: 10
# font_size: 12
size_hint=(1, .5), text=caption)
self.add_widget(lbl)
self.spinner = Spinner(
# default value shown
text=s_text,
# available values
values=values,
# just for positioning in our example
size_hint=(1, .5),
#size=(100, 44),
#pos_hint={'center_x': .5, 'center_y': .5}
)
if action is not None:
self.spinner.bind(text=self.use_selected_value)
self.add_widget(self.spinner)
def use_selected_value(self, spinner, text):
self.action(text)
示例3: titlebar
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def titlebar(self):
layout=BoxLayout(padding='2sp',size_hint=(1,None),height='65sp')
layout.orientation='horizontal'
#credentials = self.accept_credentials()
self.submit_popup = Popup(title='Enter credentials',content=self.accept_credentials(),size_hint=(0.6, 0.35))
#credentials.children[1].bind(on_press=self.submit_popup.dismiss)
submit = Button(text='Submit',size_hint=(0.4,1))
if self.element.read_token(self):
submit.bind(on_press=partial(self.submit_assignment))
else:
submit.bind(on_press=self.submit_popup.open)
run = Button(text='Run',size_hint=(0.4,1))
run.bind(on_press=self.run)
ex_dropdown = Spinner(text=self.current_ex,size_hint=(1,1))
ex_dropdown.values = os.listdir('./res/')
ex_dropdown.bind(text=self.updateExercise)
layout.add_widget(run)
layout.add_widget(ex_dropdown)
layout.add_widget(submit)
return layout
示例4: build
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def build(self):
b = BoxLayout(orientation='vertical')
languages = Spinner(
text='language',
values=sorted(['KvLexer', ] + list(lexers.LEXERS.keys())))
languages.bind(text=self.change_lang)
menu = BoxLayout(
size_hint_y=None,
height='30pt')
fnt_size = Spinner(
text='12',
values=list(map(str, list(range(5, 40)))))
fnt_size.bind(text=self._update_size)
fonts = [
file for file in LabelBase._font_dirs_files
if file.endswith('.ttf')]
fnt_name = Spinner(
text='RobotoMono',
option_cls=Fnt_SpinnerOption,
values=fonts)
fnt_name.bind(text=self._update_font)
mnu_file = Spinner(
text='File',
values=('Open', 'SaveAs', 'Save', 'Close'))
mnu_file.bind(text=self._file_menu_selected)
key_bindings = Spinner(
text='Key bindings',
values=('Default key bindings', 'Emacs key bindings'))
key_bindings.bind(text=self._bindings_selected)
menu.add_widget(mnu_file)
menu.add_widget(fnt_size)
menu.add_widget(fnt_name)
menu.add_widget(languages)
menu.add_widget(key_bindings)
b.add_widget(menu)
self.codeinput = CodeInputWithBindings(
lexer=KivyLexer(),
font_size=12,
text=example_text,
key_bindings='default',
)
b.add_widget(self.codeinput)
return b
示例5: MenuWidget
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
class MenuWidget(FloatLayout):
def __init__(self, **kwargs):
super(MenuWidget, self).__init__(**kwargs)
default_choice = "demo_tiles"
self.choices = {
"demo_text": "Text drawing",
"demo_bounce": "Basic physics simulation",
"demo_starship": "'Endless' scrolling background and animation",
"demo_tiles": "Tile map scrolling",
"demo_pong": "Simple Pong game",
"demo_breakout": "Breakout implemented with physical mover",
"demo_collision": "Optimized collision checking demo/test",
"demo_collision_1": "Simple collision test case",
"demo_control_1": "Demonstrates a more complex control scheme",
}
layout = StackLayout(orientation="tb-lr", padding=[10, 20, 10, 20])
layout.add_widget(Image(source="assets/img/ui/logo.png", size_hint=(1, 0.4)))
layout.add_widget(Label(text="Choose demo:", size_hint=(1, 0.1)))
self.spinner = Spinner(text=default_choice, values=[x for x in self.choices.iterkeys()], size_hint=(1, 0.1))
layout.add_widget(self.spinner)
self.spinner.bind(text=self.show_selected_value)
self.description_label = Label(text=self.choices[default_choice], valign="middle", halign="center", size_hint=(1, 0.3))
self.description_label.bind(size=self.description_label.setter("text_size"))
layout.add_widget(self.description_label)
run_button = Button(text="Run", size_hint=(1, 0.1))
run_button.bind(state=self.on_run)
layout.add_widget(run_button)
self.add_widget(layout)
def show_selected_value(self, spinner, value):
self.description_label.text = self.choices[value]
def on_run(self, instance, value):
if self.parent:
parent = self.parent
parent.remove_widget(self)
state = None
exec("state = %s.create(float(Window.width), float(Window.height), float(tile_size))" % self.spinner.text)
parent.add_widget(ScreenWidget(state))
示例6: getUI
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def getUI(self):
"""get the ui element"""
if 'enum' in self._typeInfo:
result = Spinner()
result.values = self._typeInfo['enum']
elif self._typeInfo['type'].lower() == 'boolean':
result = Spinner()
result.values = ['true', 'false']
else:
result = TextInput()
if self.value:
result.text = self.value.lower()
skin = sm.getSkin('text', self.asset)
result.size = sm.getControlSize(skin, self.asset)
self.uiEl = result
self.prepareUiElement()
result.bind(text=self.value_changed)
return result
示例7: __init__
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def __init__(self, *args, **kwargs):
super(MapBrowser, self).__init__(**kwargs)
mapview = MapView(lat=50.6394,
lon=3.057,
zoom=8,
cache_dir="cache")
self.add_widget(mapview)
mapview.add_widget(MapMarker(lat=50.6394, lon=3.057))
mapview.add_widget(MapMarker(lat=-33.867, lon=151.206))
top_bar = Toolbar(pos_hint={'top': 1})
def center_on(lat, lon, instance):
mapview.center_on(lat, lon)
label_lat.text = "Latitude: {}".format(mapview.lat)
label_lon.text = "Longitude: {}".format(mapview.lon)
btn_lille = Button(text="Move to Lille, France")
btn_lille.bind(on_release=partial(center_on, 50.6394, 3.057))
top_bar.add_widget(btn_lille)
btn_sydney = Button(text="Move to Sydney, Autralia")
btn_sydney.bind(on_release=partial(center_on, -33.867, 151.206))
top_bar.add_widget(btn_sydney)
spinner_src = Spinner(text="mapnik", values=MapSource.providers.keys())
def set_source(instance, selected_text):
mapview.map_source = selected_text
spinner_src.bind(text=set_source)
top_bar.add_widget(spinner_src)
bottom_bar = Toolbar()
label_lon = Label(text="Longitude: {}".format(mapview.lon))
label_lat = Label(text="Latitude: {}".format(mapview.lat))
bottom_bar.add_widget(label_lon)
bottom_bar.add_widget(label_lat)
self.add_widget(top_bar)
self.add_widget(bottom_bar)
示例8: show_personal_info
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def show_personal_info(self):
content = BoxLayout(orientation='vertical')
scroll_view = ScrollView(do_scroll_x=False)
self.personal_info_bottom_layout = GridLayout(cols=2, spacing='5dp', size_hint_x=1, size_hint_y=None,
row_default_height='30dp', row_force_default=True)
self.personal_info_bottom_layout.bind(minimum_height=self.personal_info_bottom_layout.setter('height'))
key_dropdown = Spinner(values=[key['public'] for key in json.load(open('api_keys.json'))], size_hint=(1, None),
height=50, text='Choose an API Key')
key_dropdown.bind(text=self.load_personal_info)
content.add_widget(key_dropdown)
scroll_view.add_widget(self.personal_info_bottom_layout)
content.add_widget(scroll_view)
button_layout = BoxLayout(size_hint=(1, 0.1))
button = Button(text=self.PlungeApp.get_string('Close'), size_hint=(1, None), height=50)
button_layout.add_widget(button)
content.add_widget(button_layout)
title = "Personal Stats"
self.info = Popup(title=title, content=content, auto_dismiss=False, size_hint=(.7, .7))
button.bind(on_press=self.close_info)
self.info.open()
return
示例9: __init__
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def __init__(self, **kwargs):
kwargs['orientation'] = 'vertical'
super(MainWindow, self).__init__(**kwargs)
spinner = Spinner(
# default value shown
text='Home',
# available values
values=('Home', 'Test', 'AddWord'),
# just for positioning in our example
size_hint=(1, None),
size=(100, 44),
pos_hint={'center_x': .5, 'center_y': .5})
spinner.bind(text=self.set_page_vidget)
self.add_widget(spinner)
self.work_area = BoxLayout()
self.work_area.add_widget(Home())
self.add_widget(self.work_area)
示例10: build_alarm_popup
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def build_alarm_popup(self):
layout = BoxLayout(orientation='horizontal')
hourspin = Spinner(text=str(self.hour),
values=list(map(str, list(range(1, 25)))),
sync_height=True,
font_size=(self.height/4.0),
option_cls=SpinnerButton)
hourspin.bind(text=self.set_hour)
minspin = Spinner(text=str(self.minutes),
values=list(map(str, list(range(1, 60)))),
sync_height=True,
font_size=(self.height/4.0),
option_cls=SpinnerButton)
minspin.bind(text=self.set_minute)
layout.add_widget(hourspin)
layout.add_widget(minspin)
return layout
示例11: add_row
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def add_row(self, instance):
"""
Add a row to the main exchange screen
:param instance:
:return:
"""
self.num_rows += 1
keys_button = Button(text='Keys', size_hint_x=0.2, id='%d' % self.num_rows)
keys_button.bind(on_release=self.enter_keys)
self.content.add_widget(keys_button)
self.keys_button.append(keys_button)
address = TextInput(size_hint_x=0.2, padding=[6, 10, 6, 10],
multiline=False, font_size=18, id='%d' % self.num_rows)
address.bind(text=self.check_address)
self.content.add_widget(address)
self.address.append(address)
unit = Spinner(values=self.currencies, text=self.currencies[0], size_hint_x=0.2, id='%d' % self.num_rows)
self.selected_unit = self.currencies[0]
unit.bind(text=self.set_unit)
self.content.add_widget(unit)
self.unit.append(unit)
rates = Button(text='Rates', size_hint_x=0.2, id='%d' % self.num_rows)
rates.bind(on_release=self.enter_rates)
self.content.add_widget(rates)
self.rates.append(rates)
bot = Spinner(values=self.bots, text=self.bots[0], size_hint_x=0.2, id='%d' % self.num_rows)
self.selected_bot = self.bots[0]
bot.bind(text=self.set_bot)
self.content.add_widget(bot)
self.bot.append(bot)
if isinstance(instance, dict):
keys_button.text = instance['public'][:8] + ' / ' + instance['secret'][:8]
address.text = instance['address']
unit.text = instance['unit']
rates.text = instance['ask'] + ' | ' + instance['bid']
bot.text = instance['bot']
示例12: build
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def build(self):
b = BoxLayout(orientation='vertical')
languages = Spinner(
text='language',
values=sorted(['KvLexer', ] + list(lexers.LEXERS.keys())))
languages.bind(text=self.change_lang)
menu = BoxLayout(
size_hint_y=None,
height='30pt')
fnt_size = Spinner(
text='12',
values=list(map(str, list(range(5, 40)))))
fnt_size.bind(text=self._update_size)
fnt_name = Spinner(
text='DroidSansMono',
option_cls=Fnt_SpinnerOption,
values=sorted(map(str, fonts.get_fonts())))
fnt_name.bind(text=self._update_font)
mnu_file = Spinner(
text='File',
values=('Open', 'SaveAs', 'Save', 'Close'))
mnu_file.bind(text=self._file_menu_selected)
menu.add_widget(mnu_file)
menu.add_widget(fnt_size)
menu.add_widget(fnt_name)
menu.add_widget(languages)
b.add_widget(menu)
self.codeinput = CodeInput(
lexer=KivyLexer(),
font_name='data/fonts/DroidSansMono.ttf', font_size=12,
text=example_text)
b.add_widget(self.codeinput)
return b
示例13: print
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
post_response = api_requests.add_sensor(url_text.text, login_text.text, pass_text.text, type_id, type_name, device_name, device_id)
if checkbox.active is True:
added_device_id = api_requests.get_device_id(url_text.text, login_text.text, pass_text.text, post_response[3])
print(post_response[3], added_device_id)
add_to_hub_resp = api_requests.add_to_hub(url_text.text, login_text.text, pass_text.text, hub_id, added_device_id)
textbox.text = "SENT QUERY: \n" + str(post_response[0]) + "\nSERVER REPLY: " + str(post_response[1]) + "\nADD TO PORTAL: "\
+ str(post_response[2]) + "\nADDED TO HUB: " + str(add_to_hub_resp)
else:
textbox.text = "SENT QUERY: \n" + str(post_response[0]) + "\nSERVER REPLY: " + str(post_response[1]) + "\nADD TO PORTAL: "\
+ str(post_response[2])
# ACTIONS
button1.bind(on_press=get_types_pressed)
button2.bind(on_press=add_device_action)
type_spinner.bind(text=spinner_clicked)
# MAIN CLASS
class IoTHelperApp(App):
def build(self):
return layout
# BASE PROGRAM
if __name__ == "__main__":
IoTHelperApp().run()
示例14: build
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
def build(self):
self.robot = Robot(status_display=self, code_display=self,
on_disconnect=self._on_disconnect,
on_stiffness=self._on_chain_stiffness_from_robot)
# building Kivy Interface
b = BoxLayout(orientation='vertical')
menu = BoxLayout(
size_hint_y=None,
height='30pt')
fnt_name = Spinner(
text='DroidSansMono',
option_cls=Fnt_SpinnerOption,
values=sorted(map(str, fonts.get_fonts())))
fnt_name.bind(text=self._update_font)
# file menu
mnu_file = Spinner(
text=localized_text('file_menu_title'),
values=(localized_text('file_connect'),
localized_text('file_open'),
localized_text('file_save_as'),
localized_text('file_save'),
localized_text('file_close')))
mnu_file.bind(text=self._file_menu_selected)
# motors on/off
btn_motors = ToggleButton(text=localized_text('motors_on'),
state='normal',
background_down='stiff.png',
background_normal='relaxed.png')
btn_motors.bind(on_press=self._on_motors)
self._motor_toggle_button = btn_motors
btn_speech = ToggleButton(text=localized_text('speech_recognition'),
state='down' if self.robot.is_speech_recognition_enabled else 'normal')
btn_speech.bind(on_press=self._on_toggle_speech_recognition)
btn_touch_sensors = ToggleButton(text=localized_text('touch_sensors'),
state='down' if self.robot.is_touch_sensors_enabled else 'normal')
btn_touch_sensors.bind(on_press=self._on_toggle_touch_sensors)
# run script
btn_run_script = Button(text=localized_text('run_script'))
btn_run_script.bind(on_press=self._on_run_script)
self.btn_run_script = btn_run_script
# root actions menu
robot_actions = Spinner(
text=localized_text('action_menu_title'),
values=sorted(self.robot.postures()))
robot_actions.bind(text=self.on_action)
# add to menu
menu.add_widget(mnu_file)
menu.add_widget(btn_speech)
menu.add_widget(btn_touch_sensors)
menu.add_widget(btn_motors)
menu.add_widget(btn_run_script)
menu.add_widget(robot_actions)
b.add_widget(menu)
controls = BoxLayout(
size_hint_y=None,
height='30pt')
# add keyframe
btn_add_keyframe = Button(text=localized_text('add_keyframe'))
btn_add_keyframe.bind(on_press=self._on_add_keyframe)
controls.add_widget(btn_add_keyframe)
# set read joint angles to enable animation to start from known position
btn_update_joints = Button(text=localized_text('read_joints'))
btn_update_joints.bind(on_press=self._on_read_joints)
controls.add_widget(btn_update_joints)
kf_duration_label = Label(text=localized_text('keyframe_duration_colon'))
controls.add_widget(kf_duration_label)
kf_duration_input = TextInput(text=str(self.robot.keyframe_duration), multiline=False)
kf_duration_input.bind(text=self._on_keyframe_duration)
controls.add_widget(kf_duration_input)
# allow user to select which translator to use
active_translator = Spinner(
text=self.robot.get_translator_name(),
values=get_translator_names())
active_translator.bind(text=self._on_translator_changed)
controls.add_widget(active_translator)
self.active_translator = active_translator
self.is_translator_cancel = False
b.add_widget(controls)
m = BoxLayout()
code_status = BoxLayout(orientation='vertical', size_hint=(0.6, 1))
# code input
self.codeinput = CodeInput(
#.........这里部分代码省略.........
示例15: Spinner
# 需要导入模块: from kivy.uix.spinner import Spinner [as 别名]
# 或者: from kivy.uix.spinner.Spinner import bind [as 别名]
from kivy.uix.spinner import Spinner
from kivy.base import runTouchApp
spinner = Spinner(
text='Home',
values=('Home', 'Work', 'Other', 'Custom'),
size_hint=(None, None), size=(100, 44),
pos_hint={'center_x': .5, 'center_y': .5})
def show_selected_value(spinner, text):
print('The spinner', spinner, 'have text', text)
spinner.bind(text=show_selected_value)
runTouchApp(spinner)