Python 3.x Kivy on_发布,创建新选项卡
我有这个密码。是否有人可以帮助我使用Python 3.x Kivy on_发布,创建新选项卡,python-3.x,tabs,kivy,self,Python 3.x,Tabs,Kivy,Self,我有这个密码。是否有人可以帮助我使用If语句或任何可以在发布时调用事件以创建新选项卡的代码 def load_songs(self, storageLocation): songs = [] if Path('Books').is_dir(): for filename in storageLocation.glob('**/*.wav'): songs.append(filename) # Create subfolder(Chapter)
If语句
或任何可以在发布时调用事件以创建新选项卡的代码
def load_songs(self, storageLocation):
songs = []
if Path('Books').is_dir():
for filename in storageLocation.glob('**/*.wav'):
songs.append(filename)
# Create subfolder(Chapter)
booksdir = [f for f in storageLocation.iterdir() if f.is_dir()]
for value, Bookfolders in enumerate(booksdir):
#create OneLineListItem(or Button) for each subfolder
self.root.ids.Books.add_widget(OneLineListItem(text=str(Bookfolders), pos_hint={"center_x": 1, "center_y": 1}, ))
> #Here I want a statement that would create a new Tab using the line below whenever the OneLineListItem above is clicked I also intend to close it whenever the user leaves the Tab.
self.root.ids.tabs.add_widget(Tab(title="yea",))
通过更多的研究,对于任何感兴趣的人,我发现使用lambda解决了这个问题self.root.ids.Books.add_小部件(OneLineListItem(text=str(Bookfolders),pos_-hint={“center_x”:1,“center_y”:1},on_release=lambda*args:self.root.ids.tabs.add_小部件(Tab(title=f“Tab{Bookfolders}”))
从一个问题中得到了线索,但问题现在只是第一个项目起作用了。循环中的其余项似乎没有响应