数据库中特定项上的kivy python弹出窗口
因此,我使用Kivy用Python构建了一个基本的名字和记事本(档案本身)。我很好奇如何能够点击一个名字,让它提供更多的信息(关于这个人的注释)。我看到了CustomPopup()功能,但这似乎更具体地针对一个设置项,而我希望能够单击任何名称并使注释可见。只要朝着正确的方向走一点就太棒了,谢谢 这是一些代码,我对编程非常陌生,所以这是从Derek Banas那里剽窃来的,以满足我当前的需要 Python方面:数据库中特定项上的kivy python弹出窗口,python,kivy,Python,Kivy,因此,我使用Kivy用Python构建了一个基本的名字和记事本(档案本身)。我很好奇如何能够点击一个名字,让它提供更多的信息(关于这个人的注释)。我看到了CustomPopup()功能,但这似乎更具体地针对一个设置项,而我希望能够单击任何名称并使注释可见。只要朝着正确的方向走一点就太棒了,谢谢 这是一些代码,我对编程非常陌生,所以这是从Derek Banas那里剽窃来的,以满足我当前的需要 Python方面: from kivy.app import App from kivy.uix.bo
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.uix.listview import ListItemButton
from kivy.uix.popup import Popup
class HumanListButton(ListItemButton):
pass
class CustomPopup(Popup):
pass
class HumanDB(BoxLayout):
first_name_text_input = ObjectProperty()
last_name_text_input = ObjectProperty()
notes_input = ObjectProperty()
human_list = ObjectProperty()
def submit_human(self):
# get the human name from textinput, synatx is to use varriable of the textinput.text
human_name = self.first_name_text_input.text + " " + self.last_name_text_input.text + " Notes: " + self.notes_input.text
# add to list view
self.human_list.adapter.data.extend([human_name])
# reset the listview, this makes sure it gets updated
self.human_list._trigger_reset_populate()
def delete_human(self):
# this is where banas talks about building a database
# if a list item is selected
if self.human_list.adapter.selection:
# get the text from the item selected
selection = self.human_list.adapter.selection[0].text
# remove the matching human
self.human_list.adapter.data.remove(selection)
# reset the listview
self.human_list._trigger_reset_populate()
def replace_human(self):
# if a list item is selected
if self.human_list.adapter.selection:
# get the human name from textinput
selection = self.human_list.adapter.selection[0].text
# remove matching item
self.human_list.adapter.data.remove(selection)
# get the huamn name from TextInputs
human_name = self.first_name_text_input.text + " " + self.last_name_text_input.text + " Notes: " + self.notes_input.text
# add the updated data to the list
self.human_list.adapter.data.extend([human_name])
# reset the listview
self.human_list._trigger_reset_populate()
def open_popup(self):
the_popup = CustomPopup()
the_popup.open()
class HumanDBApp(App):
def build(self):
return HumanDB()
dbApp = HumanDBApp()
dbApp.run()
暗示
使用名称的循环视图。单击任何姓名时,用此人的笔记填充弹出窗口小部件的内容
自1.10.0版以来已弃用:已弃用,请使用
相反
例子