Hi guys & gals...
So I have this code that populates my Carousel with images from the path....
Python Code snippet...
And in string snippet I have the following...
I want a function that can be called to get the name of the image as I swipe on the carousel to be printed...
This is what i have that does not work...Do i need to bind this somewhere...
Thus far for the past 5 days I have posted other queries in many other forums and sadly no responses received...
I'm hoping this forum is more forthcoming...
So I have this code that populates my Carousel with images from the path....
Python Code snippet...
Python:
class EzLaunchScreen(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)
img_path = ('D:\\Steven\Desktop\\Python App\\Images\\Carousel\\')
# Funtion get images int carousel...
layout = FloatLayout()
self.background_image = Image(source='Images\launchScreen.png')
carousel_widget = Carousel(direction ='right')
for img_file in os.listdir(img_path):
if img_file.endswith(('.png', '.jpg', '.jpeg')):
img = Image(source=os.path.join(img_path, img_file))
print(f"Adding image: {img_file}")
carousel_widget.add_widget(img)
layout.add_widget(self.background_image)
layout.add_widget(carousel_widget)
self.add_widget(layout)
And in string snippet I have the following...
Code:
BoxLayout:
# This is the carousel library of brands...
Carousel:
id: carousel_widget
direction: 'right'
on_index: root.on_carousel_swipe()
I want a function that can be called to get the name of the image as I swipe on the carousel to be printed...
This is what i have that does not work...Do i need to bind this somewhere...
Python:
# Funtion get image name
def on_carousel_swipe(carousel_widget, instance, value):
current_image = carousel_widget.ids.carousel_widget.slides[int(value)]
img_name = current_image.source.split('\\')[-1]
img_name = img_name.split('.')[0]
print (img_name)
Thus far for the past 5 days I have posted other queries in many other forums and sadly no responses received...
I'm hoping this forum is more forthcoming...