本文整理汇总了Python中kivy.uix.dropdown.DropDown类的典型用法代码示例。如果您正苦于以下问题:Python DropDown类的具体用法?Python DropDown怎么用?Python DropDown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DropDown类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: acilirKutu
class acilirKutu(App):
def secim(self, nesne):
# Önceden seçilmiş bir düğme var ise, arka plan rengini
# ön tanımlı renge dönüştürelim
if self.acilirkutu.secim:
self.acilirkutu.secim.background_color= [1, 1, 1, 1]
self.acilirkutu.select(nesne.text)
self.anadugme.text=nesne.text
# secim özelliğine yeni nesneyi ekleyelim ve
# arka plan rengini kırmızı yapalım
self.acilirkutu.secim=nesne
nesne.background_color= 1, 0, 0, 1
def build(self):
duzen = BoxLayout()
self.anadugme = Button(text='Başlat', size_hint=(None, None))
self.acilirkutu = DropDown()
self.acilirkutu.secim=None
for x in ( "Mustafa", "Dilek", "Fatih", "Melike"):
dugme=Button(text=x, size_hint_y=None, height=25)
dugme.bind(on_release=self.secim)
self.acilirkutu.add_widget(dugme)
self.anadugme.bind(on_release=self.acilirkutu.open)
duzen.add_widget(self.anadugme)
return duzen
示例2: Uygulama
class Uygulama(App):
def secim(self,nesne):
if nesne.text=="mavi":
self.resim.color=(0,0,1,1)
elif nesne.text=="kirmizi":
self.resim.color=(1,0,0,1)
elif nesne.text=="yeşil":
self.resim.color=(0,1,0,1)
self.dropdown.select(nesne.text)
self.anaDugme.text=nesne.text
def build(self):
self.renkler=(["mavi"],["kirmizi"],["yeşil"])
duzen=BoxLayout()
self.dropdown=DropDown()
self.resim=Image()
for renk in self.renkler:
dugme=Button(text=renk[0],size_hint_y=None,height=50)
dugme.bind(on_relase=self.secim)
self.dropdown.add_widget(dugme)
self.anaDugme=Button(text="Renkler",size_hint=(None,None))
self.anaDugme.bind(on_relase=self.dropdown.open)
duzen.add_widget(self.anaDugme)
duzen.add_widget(self.resim)
return duzen
示例3: SettingsScreen
class SettingsScreen(ActionBarScreen):
STR_SETTINGS = StringProperty()
STR_RESET_DEFAULTS = StringProperty()
STR_RESET_DEFAULTS_HELP = StringProperty()
STR_RESET = StringProperty()
STR_LANGUAGE_CHANGE = StringProperty()
def __init__(self, **kwargs): # inicializace
self.root = kwargs['root']
self.root.insertStrings.append((self, ))
super(SettingsScreen, self).__init__(**kwargs)
self.dropdown = DropDown()
for index in LANGUAGES.itervalues():
btn = Button(text=index, size_hint_y=None, height=44, font_size='24dp', font_name="font/Roboto-Regular.ttf")
btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
self.dropdown.add_widget(btn)
self.language.bind(on_release=self.dropdown.open)
self.dropdown.bind(on_select=lambda instance, x: setattr(self.language, 'text', x))
self.language.bind(text=self.change)
def reset_defaults(self, *args):
# Výmaz konfiguračního souboru po stisku tlačítka reset
self.root.Cfg = ['' for y in range(4)]
self.root.refreshCfg()
def on_pre_enter(self, *args):
# Před vstupem na obrazovku načte jazyky
self.language.text = LANGUAGES.get(self.root.Cfg[0])
def change(self, *args):
# Změní jazyk, znovu načte řetězce
self.root.Cfg[0] = [y[0] for y in LANGUAGES.items() if y[1] == self.language.text][0]
self.root.refreshCfg()
self.root.doStrInsert()
示例4: DropDownCreation
def DropDownCreation(data):
Dropdown = DropDown()
for i in data:
drop_option = Button(text = i, size_hint_y = None, height = 40)
drop_option.bind(on_release = lambda drop_option: Dropdown.select(drop_option.text))
Dropdown.add_widget(drop_option)
return Dropdown
示例5: update_action_button
def update_action_button(self):
action_button = self.ids.action_button
options = (
ActionButtonOption(text=_('Sign'), func=lambda btn: self.do_sign(), enabled=self.can_sign),
ActionButtonOption(text=_('Broadcast'), func=lambda btn: self.do_broadcast(), enabled=self.can_broadcast),
ActionButtonOption(text=_('Bump fee'), func=lambda btn: self.do_rbf(), enabled=self.can_rbf),
ActionButtonOption(text=_('Remove'), func=lambda btn: self.remove_local_tx(), enabled=self.is_local_tx),
)
num_options = sum(map(lambda o: bool(o.enabled), options))
# if no options available, hide button
if num_options == 0:
action_button.disabled = True
action_button.opacity = 0
return
action_button.disabled = False
action_button.opacity = 1
if num_options == 1:
# only one option, button will correspond to that
for option in options:
if option.enabled:
action_button.text = option.text
self._action_button_fn = option.func
else:
# multiple options. button opens dropdown which has one sub-button for each
dropdown = DropDown()
action_button.text = _('Options')
self._action_button_fn = dropdown.open
for option in options:
if option.enabled:
btn = Button(text=option.text, size_hint_y=None, height=48)
btn.bind(on_release=option.func)
dropdown.add_widget(btn)
示例6: __init__
def __init__(self, **kwargs):
super(UpdateScreen, self).__init__(**kwargs)
self.cols = 2
dropDown = DropDown()
for index in range(10):
btn = Button(Text="Value %d" % index, size_hint_y=None, height=44)
dropDown.add_widget(btn)
self.add_widget(dropDown)
示例7: LeaderBoardLayout
class LeaderBoardLayout(Widget):
def __init__(self, **kwargs):
""" Creates the buttons, text inputs and labels to be used by the other functions
:param kwargs:
:return:
"""
super(LeaderBoardLayout, self).__init__(**kwargs)
self.choice_button = Button(text="Get results")
self.results_label = Label(text="High scores", font_size="20sp")
self.name_input = TextInput(text="Enter username here.", multiline=False)
self.options_dropdown = DropDown()
self.dropdown_button = Button(text="Select an option")
self.dropdown_button.bind(on_release=self.options_dropdown.open)
self.layout = GridLayout(rows=5)
self.drop_down_options = ["Top 10 Scores", "Add New User", "Top scores for user"]
self.selected_url = "None"
def create_layout(self):
"""Adds the objects created in __init__ to a GridLayout and creates a drop down
:return:
"""
self.choice_button.bind(on_press=self.callback)
for d in self.drop_down_options:
btn = Button(text=d, size_hint_y=None, height=44)
btn.bind(on_release=lambda btn: self.options_dropdown.select(btn.text))
self.options_dropdown.add_widget(btn)
self.options_dropdown.bind(on_select=lambda instance, x: setattr(self.dropdown_button, "text", x))
self.layout.add_widget(self.dropdown_button)
self.layout.add_widget(self.name_input)
self.layout.add_widget(self.choice_button)
self.layout.add_widget(self.results_label)
return self.layout
def server_results(self, request, results):
""" Outputs the request result into a label
"""
self.results_label.text = str(results)
def callback(self, event):
"""Depending on which drop down option was selected a request a URL is
chosen to request data from teh server. """
playername = self.name_input.text[:3]
self.name_input.text = playername
self.results_label.text = "Getting scores"
if self.dropdown_button.text == "Top 10 Scores":
self.selected_url = "http://bsccg04.ga.fal.io/top10.py"
elif self.dropdown_button.text == "Add New User":
self.selected_url = "http://bsccg04.ga.fal.io/new_user.py?playername=" + playername
elif self.dropdown_button.text == "Top scores for user":
self.selected_url = "http://bsccg04.ga.fal.io/users_high_score.py?playername=" + playername
request = UrlRequest(self.selected_url, self.server_results)
示例8: addButtons
def addButtons(self):
for i, button_text_label in enumerate(self.buttonList):
temp_button = MyButton(text = button_text_label)
#if these two colors are not redefined in the inherited class, the default is used
temp_button.color = self.menu_color_letters
temp_button.background_color = [.8, .7,0, .9]
#now add dropdown buttons
dropdown = DropDown()
#if in parameter settings, combine dict to string
if i is 1:
for y in self.paradigm_setup_values:
submenu_string = y+': '+str(self.paradigm_setup_values[y])
btn = Button(text=submenu_string, size_hint_y=None, height=44)
btn.background_color = [.8, .9,.7, .9]
btn.bind(on_release=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(btn)
else:
for submenu_string in self.menu_items[i]:
# when adding widgets, we need to specify the height manually (disabling
# the size_hint_y) so the dropdown can calculate the area it needs.
btn = Button(text=submenu_string, size_hint_y=None, height=44)
btn.background_color = [.8, .9,.7, .9]
# for each button, attach a callback that will call the select() method
# on the dropdown. We'll pass the text of the button as the data of the
# selection.
btn.bind(on_release=lambda btn: dropdown.select(btn.text))
#then add the button inside the dropdown
dropdown.add_widget(btn)
#bind the dropdown to the main menu button
temp_button.bind(on_release = dropdown.open)
dropdown.bind(on_select=lambda instance, x: self.menu_function_handler(x))
#get info about what has been pressed
#dropdown.bind(on_select=lambda instance, x: setattr(temp_button, 'text', x))
self.layout_top_menu.add_widget(temp_button)
示例9: populate_drop_down
def populate_drop_down(self, entries, attribute, location):
"""Populate a drop down menu."""
drop_down = DropDown()
for entry in entries:
Logger.info("populate dropdown for {}: {}"
"".format(attribute, entry))
button = Button(
text=entry.name, height=44, size_hint_y=None,
on_release=lambda a, entry=entry:
setattr(self, attribute, entry))
drop_down.add_widget(button)
drop_down.open(location)
示例10: MyDrop
class MyDrop(App):
def __init__(self, **kwargs):
super(MyDrop, self).__init__(**kwargs)
api = 'http://127.0.0.1:3000/api/1.0/places.json'
resp = requests.get(api)
places = []
try:
if not resp.status_code == 200:
raise Exception('ApiException', 'Error found while calling the API backend')
for data in [resp.json()[key] for key in resp.json().keys() if key == 'data']:
for place in data:
places.append(place['name'])
self.lista = tuple(places)
except Exception as err:
return err
def d(self, n):
self.dropdown.select(n.text)
def build(self):
self.box = FloatLayout()
self.l = Label(pos_hint={'x': 0.5 / 2, 'center_y': 0.9},
size_hint=(0.5, 0.2),
text='[color=ff3333][b][size=35]TARIFAS DE TAXI[/b][/color]',
markup=True)
self.dropdown = DropDown()
for i in self.lista:
b1 = Button(text=i, size_hint_y=None, height=50)
b1.bind(on_release=self.d)
self.dropdown.add_widget(b1)
self.b2 = Button(pos_hint={'x': 0, 'center_y': .4},
size_hint=(0.5, 0.2),
text='[color=3333ff][size=24]ORIGEN[/color]',
markup=True)
self.b2.bind(on_release=self.dropdown.open)
self.b3 = Button(pos_hint={'x': 0.5, 'center_y': .4}, size_hint=(0.5, 0.2),
text='[color=3333ff][size=24]DESTINO[/color]', markup=True)
self.b3.bind(on_release=self.dropdown.open)
self.b_calcular = Button(pos_hint={'x': 0.5 / 2, 'center_y': .1}, size_hint=(0.5, 0.2),
text='[color=3333ff][size=24]CALCULAR TARIFA[/color]', markup=True)
self.b_calcular.bind()
self.box.add_widget(self.b2)
self.box.add_widget(self.b3)
self.box.add_widget(self.b_calcular)
self.box.add_widget(self.l)
return self.box
示例11: __init__
def __init__(self, widget, **kwargs):
super(DataBindingEditor, self).__init__(**kwargs)
dropdown = DropDown()
for variable in variables:
# when adding widgets, we need to specify the height manually (disabling
# the size_hint_y) so the dropdown can calculate the area it needs.
btn = Button(text='%s' % variable, size_hint_y=None, height=40)
# for each button, attach a callback that will call the select() method
# on the dropdown. We'll pass the text of the button as the data of the
# selection.
btn.bind(on_release=lambda btn: dropdown.select(btn.text))
# then add the button inside the dropdown
dropdown.add_widget(btn)
# create a big main button
mainbutton = Button(text=widget.variable.name, size_hint=(None, None), pos_hint={'center_x': 0.5, 'center_y': 0.5})
# show the dropdown menu when the main button is released
# note: all the bind() calls pass the instance of the caller (here, the
# mainbutton instance) as the first argument of the callback (here,
# dropdown.open.).
mainbutton.bind(on_release=dropdown.open)
# one last thing, listen for the selection in the dropdown list and
# assign the data to the button text.
dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, 'text', x))
dropdown.bind(on_select=lambda instance, x: widget.set_var(x))
self.add_widget(mainbutton)
示例12: __init__
def __init__(self, player, **kwargs):
BoxLayout.__init__(self, **kwargs)
self.queue = Queue()
self.activeslider = False
self.dropdown = DropDown()
self.stationdropdown = DropDown()
self.currentplayer = player
self.playerstatus = "Pending ...."
self.playername = self.currentplayer.group.label
self.rendering = self.currentplayer.renderingControl.subscribe(
event_queue=self.queue)
self.info = self.currentplayer.avTransport.subscribe(
event_queue=self.queue)
self.timer = Clock.schedule_interval(self.monitor, 0)
示例13: acilirKutuKv
class acilirKutuKv(App):
def secim(self, nesne):
self.acilirkutu.select(nesne.text)
self.root.ids.anadugme.text=nesne.text
def build(self):
self.root=Builder.load_string(kv)
self.acilirkutu = DropDown()
for x in ( "Mustafa", "Dilek", "Fatih", "Melike"):
dugme=Button(text=x, size_hint_y=None, height=25)
dugme.bind(on_release=self.secim)
self.acilirkutu.add_widget(dugme)
return self.root
示例14: __init__
def __init__(self, **kwargs):
super(Root, self).__init__(**kwargs)
self.sm.transition = BlurTransition()
for slide, name in self.slides:
self.sm.add_widget(slide, name)
self.dropdown = DropDown()
for name in self.sm.slide_names:
btn = Button(text=name, size_hint_y=None, height="40dp")
btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
self.dropdown.add_widget(btn)
self.sm.add_widget(Factory.EndSlide, "Fine della presentazione")
def dd_open_wrapper(*args, **kwargs):
self.dd_open = True
return self.dropdown.open(*args, **kwargs)
def dd_dismiss_wrapper(*args):
self.dd_open = False
self.controls.ddbutton.bind(on_release=dd_open_wrapper)
self.dropdown.bind(on_select=lambda instance, x: setattr(self.controls.ddbutton, 'text', x),
on_dismiss=dd_dismiss_wrapper)
self.dropdown.bind(on_select=lambda instance, x: self.sm.switch_to_slide(x))
self.controls.ddbutton.text = self.sm.current
self.sm.bind(current=self.controls.ddbutton.setter("text"))
示例15: loaded
def loaded(self, event):
if self.auto:
self.client.register(self.client.config.get('connection', '_id'))
return
self.layout.remove_widget(self.connecting_label)
del self.connecting_label
self.dropdown = DropDown()
for stage in sorted(self.client.meteor.find('stages'), key=lambda x: x['title']):
self.dropdown.add_widget(Label(text = stage['title'], size_hint_y = None, height = 40))
seen = []
for minion in sorted(self.client.meteor.find('minions',
selector = {'stage': stage['_id'], 'type': 'media'}), key=lambda x: x['title']):
# workaround for python-meteor bug
if not minion['stage'] == stage['_id']: continue
if minion['_id'] in seen: continue
else: seen.append(minion['_id'])
button = Button(text = minion['title'], size_hint_y = None, height = 30)
button.minion_id = minion['_id']
button.bind(on_press = self.do_register)
self.dropdown.add_widget(button)
self.dropdown_button = Button(text = 'Select Minion')
self.dropdown_button.bind(on_release = self.dropdown.open)
self.layout.add_widget(self.dropdown_button)
self.auto_checkbox = CheckBox()
self.auto_label = Label(text = 'Connect automatically on start')
self.layout.add_widget(self.auto_checkbox)
self.layout.add_widget(self.auto_label)