本文整理汇总了Python中kivy.uix.dropdown.DropDown.open方法的典型用法代码示例。如果您正苦于以下问题:Python DropDown.open方法的具体用法?Python DropDown.open怎么用?Python DropDown.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.dropdown.DropDown
的用法示例。
在下文中一共展示了DropDown.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showModes
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def showModes(self, relativeTo):
"""show the list of modes"""
try:
dropdown = DropDown(auto_width=True)
btn = Button(text='Disabled', markup=True, size_hint_y=None, height='44dp')
btn.bind(on_press=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(btn)
btn = Button(text='Toggle', markup=True, size_hint_y=None, height='44dp')
btn.bind(on_press=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(btn)
btn = Button(text='Button', markup=True, size_hint_y=None, height='44dp')
btn.bind(on_press=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(btn)
btn = Button(text='Analog', markup=True, size_hint_y=None, height='44dp')
btn.bind(on_press=lambda btn: dropdown.select(btn.text))
dropdown.add_widget(btn)
dropdown.bind(on_select=self.ModeSelected)
dropdown.open(relativeTo)
except Exception as e:
showError(e)
示例2: showOutputs
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def showOutputs(self, relativeTo):
"""show a list of possible outputs"""
if self.mode != 'Disabled':
try:
dropdown = DropDown(auto_width=True)
btn = Button(text="None", markup=True, size_hint_y=None, height='44dp')
btn.dataItem = None
btn.bind(on_press=lambda btn: dropdown.select(btn.dataItem))
dropdown.add_widget(btn)
for item in out.outputs:
if item.isActive == True:
btn = Button(text=str(item.number) + " (" + item.assetLabel + ")", markup=True, size_hint_y=None, height='44dp')
btn.dataItem = item
btn.bind(on_press=lambda btn: dropdown.select(btn.dataItem))
dropdown.add_widget(btn)
for item in out.relays:
if item.isActive == True:
btn = Button(text=str(item.number) + " (" + item.assetLabel + ")", markup=True, size_hint_y=None, height='44dp')
btn.dataItem = item
btn.bind(on_press=lambda btn: dropdown.select(btn.dataItem))
dropdown.add_widget(btn)
dropdown.bind(on_select=self.OutputSelected)
dropdown.open(relativeTo)
except Exception as e:
showError(e)
示例3: populate_drop_down
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
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)
示例4: NoteItem
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class NoteItem(BoxLayout):
def __init__(self, **kwargs):
super(NoteItem, self).__init__(**kwargs)
self.dropdown = DropDown()
def addNoteItem(self, w):
"""
inventoryitem = Inventarios()
inventoryitem.Clave = w.parent.txt_clave.text
inventoryitem.Producto = w.parent.txt_producto.text
inventoryitem.Existencias = w.parent.txt_existencias.text
inventoryitem.Minimo = w.parent.txt_minimo.text
inventoryitem.Maximo = w.parent.txt_maximo.text
inventoryitem.Precio = w.parent.txt_precio.text
inventoryitem.save()
"""
newitem = NoteItem()
w.text = "X"
table = app.root.ventas.lst_note
table.add_widget(newitem, index=len(table.layout.children))
app.root.ventas.txt_total.text = str(float(app.root.ventas.txt_total.text) + float(w.parent.txt_total.text))
def on_completeproduct(self, w):
print w.text
if len(w.text) > 2:
self.dropdown.clear_widgets()
# for item in app.root.inventarios:
for item in app.root.inventarios:
if w.text.upper() in item.Producto.upper():
but = WhiteButton(text=item.Producto, size_hint_y=None, height=40)
but.bind(on_press=self.fillProduct)
but.Item = item
self.dropdown.add_widget(but)
self.dropdown.open(w)
def fillProduct(self, w):
self.txt_producto.text = w.text
self.txt_precio.text = w.Item.Precio
if self.txt_cant.text != "":
self.txt_total.text = str(float(self.txt_cant.text) * float(self.txt_precio.text))
self.dropdown.dismiss()
示例5: DtbObjctDropDown
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class DtbObjctDropDown(DtbObjctDPbutton):
# Class of a DtbObjctDPbutton triggering a dropdown list on_release.
def __init__(self, **kwargs):
super(DtbObjctDropDown, self).__init__(**kwargs)
self.create_dropdown()
def create_dropdown(self):
self.dropdownlist = DropDown()
for ix in self.linked_dataframe.index:
# 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 = DtbObjctDPbutton(
linked_dataframe = self.linked_dataframe,
objct_id = ix,
attr_displayed_list = self.attr_displayed_list,
attr_backcolor = self.attr_backcolor,
size_hint = (None,None),
size = self.size
)
# 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:
self.dropdownlist.select(btn.objct_id)
)
# then add the button inside the dropdown
self.dropdownlist.add_widget(btn)
# one last thing, listen for the selection in the dropdown list and
# assign the data to the button text.
self.dropdownlist.bind(
on_select=lambda instance,
x: self.new_objct_id(objct_id = x)
)
def on_release(self):
self.dropdownlist.open(self)
示例6: ChoicePopup
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class ChoicePopup(Popup):
"""
Popup form for view schedule for group, teacher or room
"""
btn_text = StringProperty()
choices = ListProperty()
choice_input = ObjectProperty(None)
on_release = ObjectProperty(None)
dropdown = ObjectProperty(None)
def __init__(self, on_release, **kwargs):
self.on_release = on_release
super(ChoicePopup, self).__init__(**kwargs)
self.dropdown = DropDown()
self.choice_input.bind(text=self.make_dropdown, focus=self.on_focus)
self.dropdown.bind(
on_select=lambda instance, x: setattr(self.choice_input, 'text', x)
)
def make_dropdown(self, *args):
self.dropdown.clear_widgets()
for choice in self.choices:
if self.choice_input.text in choice or self.choice_input.text == '':
button = Button(
text=choice,
size_hint_y=None,
height=35
)
button.bind(
on_release=lambda btn: self.dropdown.select(btn.text)
)
self.dropdown.add_widget(button)
else:
pass
self.dropdown.open(self.choice_input)
@staticmethod
def on_focus(instance, value):
if value:
instance.text = ''
示例7: on_cinfdata
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def on_cinfdata(self, instance, value):
"""Setup the setup selection page, when the cinfdata ObjectProperty is set
(happens only on startup)"""
dropdown = DropDown()
for setup in self.cinfdata.get_setups():
btn = SetupButton(text='Setup: ' + setup['title'], size_hint_y=None,
height=44, setup=setup)
btn.bind(on_release=lambda btn: dropdown.select(btn))
dropdown.add_widget(btn)
self.mainbutton.bind(on_release=lambda widget: dropdown.open(widget))
dropdown.bind(on_select=self._select)
示例8: CompleteTextInput
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class CompleteTextInput(TextInput):
options = ListProperty([])
dd = ObjectProperty(None)
def __init__(self, **kwargs):
super(CompleteTextInput, self).__init__(**kwargs)
self.dd = DropDown(auto_dismiss=False)
self.dd.bind(on_select=self.setter('text'))
self.bind(text=self.update_complete,
focus=self.update_complete)
def update_complete(self, *args):
if self.focus:
self.dd.clear_widgets()
for x in app.settings.get('settings', 'servers').split(','):
url = x.split(';')[1].strip()
if self.text in url:
b = Factory.DDButton(text=url)
b.bind(on_release=lambda btn: self.dd.select(btn.text))
self.dd.add_widget(b)
self.dd.open(self)
else:
self.dd.dismiss()
示例9: showMainDropDown
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def showMainDropDown(self, attachTo):
dropdown = DropDown(auto_width=False, width='140dp')
btn = Button(text='%s New' % iconfonts.icon('fa-file-o'), markup=True, size_hint_y=None, height='44dp')
btn.bind(on_release=lambda btn: self.newLayout(btn.parent.parent))
dropdown.add_widget(btn)
btn = Button(text='%s Edit' % iconfonts.icon('fa-edit'), markup=True, size_hint_y=None, height='44dp')
btn.bind(on_release=lambda btn: self.editLayout(btn.parent.parent))
dropdown.add_widget(btn)
btn = Button(text='%s Credentials' % iconfonts.icon('fa-user'), markup=True, size_hint_y=None, height='44dp')
btn.bind(on_release=lambda btn: self.editCredentials(btn.parent.parent))
dropdown.add_widget(btn)
btn = Button(text='%s Capture scene' % iconfonts.icon('fa-camera'), markup=True, size_hint_y=None, height='44dp')
btn.bind(on_release=lambda btn: self.captureScene(btn.parent.parent))
dropdown.add_widget(btn)
btn = Button(text='%s Open' % iconfonts.icon('fa-folder-open-o'), markup=True, size_hint_y=None, height='44dp')
btn.bind(on_release=lambda btn: self.openLayout(btn.parent.parent))
dropdown.add_widget(btn)
dropdown.open(attachTo)
示例10: show_options
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def show_options(self, txt_inp):
input_type = self.input_type
if self.input_type == 'bool':
txt_inp.readonly = True
txt = (self.overlay_text
if txt_inp.text == '' else
txt_inp.text)
txt_inp.text = 'False' if txt[0] == 'T' else 'True'
Clock.schedule_once(lambda dt:self.defocus(txt_inp))
elif input_type.startswith('options'):
_options = input_type.split(':')[1:]
txt_inp.readonly = True
drpdn = DropDown()
for opt in _options:
drpdn.add_widget(
Button(text=opt,
background_color=(0, 0, 0, 1),
on_touch_up=partial(self.dropdown_select,
drpdn, txt_inp),
size_hint_y=None, height = '36sp'))
drpdn.open(txt_inp)
Clock.schedule_once(lambda dt: self.defocus(txt_inp))
示例11: Root
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class Root(FloatLayout):
slides = ListProperty([])
sm = ObjectProperty(None)
controls = ObjectProperty(None)
dropdown = ObjectProperty(None)
dd_open = BooleanProperty(False)
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"))
def fade_out_controls(self, *args):
if self.controls.collide_point(*Window.mouse_pos) or self.dd_open:
Clock.schedule_once(self.fade_out_controls, 1.5)
return
anim = Animation(opacity=.2, duration=1)
anim.start(self.controls)
def fade_in_controls(self, *args):
anim = Animation(opacity=.8, duration=.2)
anim.start(self.controls)
示例12: on_cinfdata
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
def on_cinfdata(self, instance, value):
"""Setup the setup selection page, when the cinfdata ObjectProperty is set
(happens only on startup)"""
dropdown = DropDown()
for setup in self.cinfdata.get_setups():
# Do not show setups that has no dateplots
if len([l for l in setup['links']
if l['pagetype'] == 'dateplot']) == 0:
continue
btn = SetupButton(text='Setup: ' + setup['title'], size_hint_y=None,
height=44, setup=setup)
btn.bind(on_release=lambda btn: dropdown.select(btn))
dropdown.add_widget(btn)
self.mainbutton.bind(on_release=lambda widget: dropdown.open(widget))
dropdown.bind(on_select=self._select)
示例13: EventHandlerTextInput
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class EventHandlerTextInput(TextInput):
'''EventHandlerTextInput is used to display/change/remove EventHandler
for an event
'''
eventwidget = ObjectProperty(None)
'''Current selected widget
:data:`eventwidget` is a :class:`~kivy.properties.ObjectProperty`
'''
eventname = StringProperty(None)
'''Name of current event
:data:`eventname` is a :class:`~kivy.properties.ObjectProperty`
'''
kv_code_input = ObjectProperty()
'''Reference to KVLangArea
:data:`kv_code_input` is a :class:`~kivy.properties.ObjectProperty`
'''
text_inserted = BooleanProperty(None)
'''Specifies whether text has been inserted or not
:data:`text_inserted` is a :class:`~kivy.properties.ObjectProperty`
'''
project_loader = ObjectProperty(None)
'''Reference to ProjectLoader
:data:`project_loader` is a :class:`~kivy.properties.ObjectProperty`
'''
info_message = StringProperty(None)
'''Message to be displayed by InfoBubble
:data:`info_message` is a :class:`~kivy.properties.StringProperty`
'''
dropdown = ObjectProperty(None)
'''DropDown which will be displayed to show possible
functions for that event
:data:`dropdown` is a :class:`~kivy.properties.ObjectProperty`
'''
def on_touch_down(self, touch):
'''Default handler for 'on_touch_down' event
'''
if self.collide_point(*touch.pos):
self.info_bubble = InfoBubble(message=self.info_message)
bubble_pos = list(self.to_window(*self.pos))
bubble_pos[1] += self.height
self.info_bubble.show(bubble_pos, 1.5)
return super(EventHandlerTextInput, self).on_touch_down(touch)
def show_drop_down_for_widget(self, widget):
'''Show all functions for a widget in a Dropdown.
'''
self.dropdown = DropDown()
list_funcs = dir(widget)
for func in list_funcs:
if '__' not in func and hasattr(getattr(widget, func), '__call__'):
btn = Button(text=func, size_hint=(None, None),
size=(100, 30), shorten=True)
self.dropdown.add_widget(btn)
btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
btn.text_size = [btn.size[0] - 4, btn.size[1]]
btn.valign = 'middle'
self.dropdown.open(self)
self.dropdown.pos = (self.x, self.y)
self.dropdown.bind(on_select=self._dropdown_select)
def _dropdown_select(self, instance, value):
'''Event handler for 'on_select' event of self.dropdown
'''
self.text += value
def on_text(self, instance, value):
'''Default event handler for 'on_text'
'''
if not self.kv_code_input:
return
self.kv_code_input.set_event_handler(self.eventwidget,
self.eventname,
self.text)
if self.text and self.text[-1] == '.':
if self.text == 'self.':
self.show_drop_down_for_widget(self.eventwidget)
elif self.text == 'root.':
self.show_drop_down_for_widget(
self.project_loader.root_rule.widget)
else:
_id = self.text.replace('.', '')
root = self.project_loader.root_rule.widget
widget = None
if _id in root.ids:
widget = root.ids[_id]
#.........这里部分代码省略.........
示例14: LoungeScreen
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class LoungeScreen(BaseScreen):
current_player_slot = NumericProperty(0)
players = ListProperty([{}] * 4)
dropdown_player = ObjectProperty()
drag_start_id = NumericProperty(-1)
drag_stop_id = NumericProperty(-1)
dragging = BooleanProperty()
def __init__(self, **kwargs):
super(LoungeScreen, self).__init__(**kwargs)
self.set_title('Aufstellung')
self.ids.topbar.hasNext = True
self.is_dropdown_open = False
self.slot_touch = None
self.__reset()
def on_enter(self):
Clock.schedule_once(lambda dt: self.__setup_player_dropdown(), 0.2)
self.current_player_slot = 0
def on_leave(self):
self.close_dropdown()
def on_next(self):
self.manager.current = 'match'
def __reset(self):
self.players = [{}] * 4
self.current_player_slot = 0
def __setup_player_dropdown(self):
# only create if not existing
if not self.dropdown_player:
self.dropdown_player = DropDown(auto_dismiss=False)
self.dropdown_player.bind(on_select=self.on_player_select)
self.dropdown_player.bind(on_dismiss=self.on_dropdown_dismiss)
players = sorted(PlayerData.get_players(), key=lambda player: player['name'])
for player in players:
btn = PlayerButton(data=player)
btn.bind(on_release=lambda btn: self.dropdown_player.select(btn.data))
self.dropdown_player.add_widget(btn)
def on_dropdown_dismiss(self, instance):
self.is_dropdown_open = False
def open_dropdown(self, slot_id):
if not self.is_dropdown_open:
obj = self.ids['p' + str(slot_id)]
self.dropdown_player.open(obj)
self.is_dropdown_open = True
def close_dropdown(self):
if self.is_dropdown_open:
self.dropdown_player.dismiss()
def on_player_select(self, instance, data):
# player was selected from dropdown list
self.dropdown_player.dismiss()
self.set_player(data)
def on_players(self, instance, value):
GameData.set_players(value)
count_players = 0
for player in self.players:
count_players = count_players + (1 if player else 0)
self.ids.topbar.isNextEnabled = (count_players == 4)
def click_player_slot(self, player_slot):
pass
def __handle_rfid(self, rfid):
# RFID --> player ID
player_id = PlayerData.get_player_by_rfid(rfid)
# player ID --> player dict
player = PlayerData.get_player_by_id(player_id)
Logger.info('ScoreTracker: RFID: {0} - ID: {1} - Player: {2}'.format(rfid, player_id, player))
# player does not exist
if player == None:
self.denied()
# player does exist
else:
if self.dropdown_player:
self.dropdown_player.dismiss()
self.set_player(player)
def highlight_player(self, slot_id):
obj = self.ids['p' + str(slot_id)].ids.playerName
HighlightOverlay(orig_obj=obj, parent=self, active=True, bold=True).animate(font_size=80, color=(1, 1, 1, 0))
def switch_players(self, slot_id_1, slot_id_2):
self.players[slot_id_1], self.players[slot_id_2] = self.players[slot_id_2], self.players[slot_id_1]
for player_id in [slot_id_1, slot_id_2]:
self.highlight_player(player_id)
SoundManager.play(Trigger.PLAYERS_SWITCHED)
def get_slot_collision(self, event):
slot_id = None
#.........这里部分代码省略.........
示例15: Pos
# 需要导入模块: from kivy.uix.dropdown import DropDown [as 别名]
# 或者: from kivy.uix.dropdown.DropDown import open [as 别名]
class Pos(BoxLayout):
def __init__(self, **kwargs):
super(Pos, self).__init__(**kwargs)
self.cliente = None
def hacerNota(self):
if self.txt_client.text == "":
MessageBoxTime(
title="Ops", size_hint=(None, None), size=(350, 120), msg="Por favor especifica el cliente", duration=2
).open()
return
elif self.cliente == None:
MessageBoxTime(
title="Espere", size_hint=(None, None), size=(350, 120), msg="Guardando cliente", duration=2
).open()
print "Realizando nota"
nota = Notas()
nota.PUser = app.root.user
nota.Total = self.txt_total.text
nota.Cliente = self.cliente
products = []
for i in self.lst_note.layout.children:
print i.txt_producto.text
products.append(
{
"Cantidad": i.txt_cant.text,
"Product": i.txt_producto.text,
"Precio": i.txt_precio.text,
"Total": i.txt_total.text,
}
)
nota.Productos = products
nota.save()
# limpiar controles de nota
self.lst_note.clear()
self.lst_note.add_widget(NoteItem())
self.txt_client.text = ""
self.txt_total.text = "0"
self.img_button.source = "plus.png"
self.cliente = None
def on_completeclient(self, w):
if not hasattr(self, "dropdown"):
self.dropdown = DropDown()
if len(w.text) > 2:
self.dropdown.clear_widgets()
found = False
for item in Clientes.Query.filter(words__all=w.text.upper().split()):
but = WhiteButton(text=item.Name, size_hint_y=None, height=40)
but.bind(on_press=self.fillClient)
but.Cliente = item
self.dropdown.add_widget(but)
found = True
if found:
self.dropdown.open(w)
def fillClient(self, w):
self.txt_client.text = w.text
self.img_button.source = "ok.png"
self.cliente = w.Cliente
self.dropdown.dismiss()
def addClient(self):
print "Adding the client: " + self.txt_client.text
self.cliente = Clientes()
self.cliente.Name = self.txt_client.text
self.cliente.PUser = app.root.user
self.cliente.save()
self.img_button.source = "ok.png"
def fillNotas(self):
print "Llenado lista de notas"
for i in app.root.notas:
print i
notareg = NoteReg()
notareg.txt_fecha.text = str(i.createdAt)
#.........这里部分代码省略.........