Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Kivy on_发布,创建新选项卡_Python 3.x_Tabs_Kivy_Self - Fatal编程技术网

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}”))
从一个问题中得到了线索,但问题现在只是第一个项目起作用了。循环中的其余项似乎没有响应