Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

App view Python vs android

Hi there guys & gals...So I am at the end of my app build and have found a strange behaviour when running on android as apposed to normal python run...


Referencing attached image...

Image.webp

LHS is way app should work as per python running...
RHS is way app runs from Android after compile...
Taking into account this is my first venture and a total newbie to python & Kivy...
My python snippet for launch screen, carousels etc here and string snippet for slider below...
Code:
class EzLaunchScreen(Screen):     
    image1 = StringProperty("")
    overlay_height = NumericProperty(szH)
    overlay_opacity = NumericProperty(0)       

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.max_height = szH
        img_path1 = os.path.join(main_path, 'Images/Carousel')
        img_path2 = os.path.join(main_path, 'Images/CarouselF')
        img_path3 = os.path.join(main_path, 'Images/LaunchScreen.png')
        # Funtion get images into carousel from path...Bottom
        layout = FloatLayout()
        # launch screen image
        self.background_image = Image(source=img_path3)
        layout.add_widget(self.background_image)

        self.carousel_widget = Carousel(direction='right', size_hint=(None, None), size=(szW, self.overlay_height))         
        # with self.carousel_widget.canvas.before:
        #     #Color(0, 0, 0, 0)
        #     self.rect = Rectangle(size=self.carousel_widget.size, pos=self.carousel_widget.pos)       
        # Load images into carousel from path...
        for img_file in os.listdir(img_path1):
            if img_file.endswith(('.png', '.jpg', '.jpeg')):                 
                if not self.image1:
                    self.image1 = img_file.split('.')[0].upper()
                    print (f"image name is '{self.image1}'")
                    print (f"image file is '{img_file}'")               
                img = Image(source=os.path.join(img_path1, img_file), size_hint=(None, None), size=(szW, self.overlay_height))
                self.carousel_widget.add_widget(img)
        layout.add_widget(self.carousel_widget)

        # Function to create an overlay container (StencilView to clip)
        self.overlay_container = StencilView(size_hint=(None, None), size=self.carousel_widget.size)

        # with self.overlay_container.canvas.before:
        #     Color(0, 0, 0, 0)  # RGBA values for transparent (0, 0, 0, 0)
        #     self.rect = Rectangle(size=self.overlay_container.size, pos=self.overlay_container.pos)

        self.carouselF_widget = Carousel(direction='right', size_hint=(None, None), size=(szW, self.overlay_height))       
        # Funtion get images into carouselF from path...Top
        for img_file in os.listdir(img_path2):
            if img_file.endswith('.png'):                 
                if not self.image1:
                    self.image1 = img_file.split('.')[0].upper()
                img = Image(source=os.path.join(img_path2, img_file), size_hint=(None, None), size=(szW, self.overlay_height))
                self.carouselF_widget.add_widget(img)
        self.overlay_container.add_widget(self.carouselF_widget)
        layout.add_widget(self.overlay_container)
        self.add_widget(layout)

Code:
<EzLaunchScreen>:
    name: 'EzLaunch'
    val_text: ToT_label
    slide_text: slider_label
    tot_text: slider_tot
 
    FloatLayout:
        # This is the slider control for alcohol levels...         
        Slider:
            background_color: 0, 0, 0, 0
            background_width: 1
            id: slider_widget       
            min: 33
            max: 794
            step: 0.25
            value: 0
            cursor_image: 'Images/slider.png'
            cursor_width: self.width * 0.75
            cursor_height: 15.05
            orientation: 'vertical'
            size_hint: None, None
            size: '368dp', '794dp'
            pos_hint: {'x': 0,'y': 0.027}
            on_value: root.slide_it(*args)
            on_value: root.update_overlay_height(self.value)

I know it has to do with my layouts and am hoping someone can offer some insight...
Thank You
Steven
 
I must add...the build does get resized to fit android...
Code:
class main(App):
    def build(self):
        # Window.left = 1675  # For display 1 on the right (1920px for a 1080p display)
        # Window.top = 50  # Top of the screen
        if(platform == 'android'):
            Window.maximize()
        else:
            Window.size = (szW, szH)
        scr = Builder.load_string(Code)
        return scr
 
So I managed top get this output below...Seems the problem is most certainly with the scaling of the two carousels...

This is the report when running the app...
04-09 17:09:58.462 9824 10082 I python : CarouselF widget size: "[368, 794]"
04-09 17:09:58.462 9824 10082 I python : Overlay container size: "[368, 794]"
04-09 17:09:58.464 9824 10082 I python : [WARNING] [Window ] maximize() is used only on desktop OSes.
04-09 17:09:58.652 9824 10082 I python : Window size: "(1080, 2107)"
04-09 17:09:58.654 9824 10082 I python : Background image size: "[100, 100]"
04-09 17:09:58.655 9824 10082 I python : image name is 'ABSOLUT'
04-09 17:09:58.655 9824 10082 I python : image file is 'Absolut.png'
04-09 17:09:58.665 9824 10082 I python : CarouselF widget size: "[368, 794]"
04-09 17:09:58.665 9824 10082 I python : Overlay container size: "[368, 794]"

So I need to make provision for this increase???

New Image.webp
Cross posted here & here
App view Python vs Android
App view Python vs android
 
So I managed top get this output below...Seems the problem is most certainly with the scaling of the two carousels...

This is the report when running the app...
04-09 17:09:58.462 9824 10082 I python : CarouselF widget size: "[368, 794]"
04-09 17:09:58.462 9824 10082 I python : Overlay container size: "[368, 794]"
04-09 17:09:58.464 9824 10082 I python : [WARNING] [Window ] maximize() is used only on desktop OSes.
04-09 17:09:58.652 9824 10082 I python : Window size: "(1080, 2107)"
04-09 17:09:58.654 9824 10082 I python : Background image size: "[100, 100]"
04-09 17:09:58.655 9824 10082 I python : image name is 'ABSOLUT'
04-09 17:09:58.655 9824 10082 I python : image file is 'Absolut.png'
04-09 17:09:58.665 9824 10082 I python : CarouselF widget size: "[368, 794]"
04-09 17:09:58.665 9824 10082 I python : Overlay container size: "[368, 794]"

So I need to make provision for this increase???

View attachment 2993
Cross posted here & here
App view Python vs Android
App view Python vs android
sounds like a css issue, frustrating... But play around with the css... Keep in mind the phone orientations
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom