本文整理汇总了Python中kivy.uix.spinner.Spinner类的典型用法代码示例。如果您正苦于以下问题:Python Spinner类的具体用法?Python Spinner怎么用?Python Spinner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Spinner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Options
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: titlebar
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
示例3: DrpDwnList
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)
示例4: build_interface
def build_interface(self):
self.label = Label(
text=self.label_text,
text_size=(self.width * 4, None),
halign='left',
valign='middle'
)
if self.setting_type == 'number':
self.changer = Slider(
min=self.setting_min,
max=self.setting_max,
value=self.setting_value
)
self.changer.bind(value=self.change_value)
elif self.setting_type == 'bool':
self.changer = RealToggleButton(
'./media/icons/delete.png',
'./media/icons/check.png',
self.change_value,
source='./media/icons/delete.png',
always_release=True
)
elif self.setting_type == 'select':
self.changer = Spinner(
text='Something',
values=self.items
)
self.changer.bind(text=self.change_value)
self.add_widget(self.label)
self.add_widget(self.changer)
示例5: MenuWidget
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: __init__
def __init__(self, **kwargs):
super(AbstractPanel, self).__init__(kwargs=kwargs, orientation='vertical')
self.panels_to_choose = {}
self.pannels_instants = []
self.panel = ScreenManager()
self.custom_config()
text, values = self.loadClases()
self.name_label = Label(text=self.get_name(),size_hint=(1, None), size = (1,44))
self.spinner = Spinner(
# default value shown
text=text,
# available values
values=values,
# just for positioning in our example
size_hint=(1, None),
size = (1,44)
)
self.spinner.bind(text=self.show_selected_value)
self.add_widget(self.name_label)
self.add_widget(self.spinner)
self.add_widget(self.panel)
示例7: print_lhand
def print_lhand(self):
self.head.clear_widgets()
self.spinner = Spinner(
text='Left Hand',
values=map(str, self.eq_n),
size_hint=(None, None),
size=(150, 44),
pos_hint={'center_x': .5, 'center_y': .5})
def show_selected_value(spinner, text):
print('The spinner', self.spinner, 'have text', text)
print(self.eq_n.index(text))
index = self.eq_n.index(text)
#
try:
if self.all_same(self.eq_weapon, Hero.Magni.lhand_weapon ):
Hero.Magni.remove_weapon("left", self.old_weapon, Hero.Magni)
Hero.Magni.add_weapon("left", self.eq_weapon[index], Hero.Magni)
self.old_weapon = self.eq_weapon[index]
Hero.Magni.print_eq2()
except:
print("errror")
self.spinner.bind(text=show_selected_value)
self.head.add_widget(self.spinner)
示例8: __init__
def __init__(self, **kwargs):
super(MainLayout, self).__init__(**kwargs)
self.Interpreter = Interpreter()
self.command_stack = []
self.cols = 2
self.orientation = "vertical"
self.padding = 10
self.workspace = Workspace()
self.command_panel = CommandPanel(self.workspace)
self.output = Output()
self.spn_menu = Spinner(text='Menu', values=('New', 'Save', 'RUN', 'Exit'), size_hint =(None, None), size=(200, 44), pos_hint={'x': .1, 'y': .9})
self.spn_menu.bind(text=self.menu_option_selected_event)
self.command_panel.draw(self.spn_menu)
self.command_panel.add_expression_btn('LET')
self.command_panel.add_expression_btn('PRINT')
self.command_panel.add_expression_btn('GOTO')
self.command_panel.add_expression_btn('IF')
self.command_panel.add_expression_btn('GOSUB')
self.command_panel.add_expression_btn('RETURN')
self.command_panel.add_expression_btn('END')
self.add_widget(self.command_panel)
self.orientation = "horizontal"
self.workspace.draw()
self.add_widget(self.workspace)
self.output.draw()
self.add_widget(self.output)
示例9: __init__
def __init__(self, arg):
self.hight_component = 30
super(ArgsGUI, self).__init__(orientation='horizontal', size_hint=(1,None), size=(1,self.hight_component))
self.arg_name = arg
arg_name = Label(text=arg,size_hint=(0.3,None), size=(1,self.hight_component))
self.spinner_options = ('from roach', 'free input')
self.arg_type = Spinner(
# default value shown
text=self.spinner_options[0],
# available values
values=self.spinner_options,
# just for positioning in our example
size_hint=(0.3, None),
size = (1,self.hight_component)
)
self.arg_type.bind(text=self.change_input)
self.arg_roach_spinner = Spinner(
# default value shown
text='',
# available values
values=['global_data', 'save_data', 'current_channel', 'fpga'],
# just for positioning in our example
size_hint=(0.4, None),
size = (1,self.hight_component)
)
self.roach_input = True
self.free_input = TextInput(size_hint=(0.4,None), size=(1,self.hight_component))
self.add_widget(arg_name)
self.add_widget(self.arg_type)
self.add_widget(self.arg_roach_spinner)
示例10: bestellung
def bestellung(self, widget):
App.my_index = -1
TischNr = widget.id
PopupFloatLayout = FloatLayout(size_hint=(1, 1))
self.PopupScrollview = CustomScrollviewPopupContent()
self.PopupScrollviewItem = CustomButton2()
App.AuswahlHauptliste = App.HauptListeDictonaries
self.PopupScrollview.data = App.AuswahlHauptliste
#content = self.PopupScrollview.ids.content
#item = self.PopupScrollviewItem
popup = Popup(title='Bestellung für Tisch ' + str(TischNr),
content= PopupFloatLayout)
BoxTop = BoxLayout(size_hint= [0.52,0.065],pos_hint={'x': 0.5, 'y': 1.005}, spacing = 5)
ButtonExit = Button(text="Exit",
#pos_hint={'x': 0.825, 'y': 1.005},
#size_hint = [0.2,0.065],
size_hint = [0.3,1],
#on_release = self.zeromyindex,
on_release = popup.dismiss)
#myindexzero = 0
#ButtonExit.bind(on_release=ButtonExit.setter('myindexzero'))
#print App.my_index
self.ButtonSpinner =Spinner(text= "Alle",
values= ("Mittag-Essen", "Getraenke", "AlcGetraenke", "Essen Alltime", "Alle"),
size_hint= [0.7,1],
#pos_hint={'x': 0.625, 'y': 1.005}
)
self.ButtonSpinner.bind(text=self.show_selected_value)
#halign: 'right'
#valign: 'top'
#PopupFloatLayout.add_widget(ButtonExit)
#PopupFloatLayout.add_widget(ButtonSpinner)
BoxTop.add_widget(self.ButtonSpinner)
BoxTop.add_widget(ButtonExit)
PopupFloatLayout.add_widget(BoxTop)
self.PopupScrollview.size_hint = [1.05,1.017]
self.PopupScrollview.center = popup.center
PopupFloatLayout.add_widget(self.PopupScrollview)
for i in App.ScrollviewButtons:
i.ids.customID.on_release = self.Optionsfenster
popup.open()
print App.ScrollviewButtons
示例11: __init__
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)
示例12: __init__
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)
示例13: __init__
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)
示例14: show_personal_info
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
示例15: getUI
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