logo
down
shadow

kivy: My screenmanager code is not working with scrollview


kivy: My screenmanager code is not working with scrollview

By : mario
Date : November 29 2020, 09:01 AM
I think the issue was by ths following , Trying to get my kivy to work with screenmanager and scrollview. I cannot see why it is not working. If I remove the scrollview and just keep it as a simple box and button (like screen 2 in code) it works fine. As soon as I try to add the scroll view with buttons all I get is a blank screen. , You need, at least, to add your root in your ScreenOne
code :
class ScreenOne(Screen):

    def __init__ (self,**kwargs):
        ...
        root = ScrollView()
        root.add_widget(Buttonlayout)
        self.add_widget(root)


Share : facebook icon twitter icon
Is it a bug in Kivy? DropDown + ScreenManager not working as expected

Is it a bug in Kivy? DropDown + ScreenManager not working as expected


By : neonX
Date : March 29 2020, 07:55 AM
will help you I've reproducable difficulties using ScreenManager and DropDown, if there are screens before the screen with the DropDown. I'm struggling with this for days now, since I'm a beginner, I assumed it's my fault here. , Can be done in many (better?) ways, but this works.
code :
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.textinput import TextInput
from kivy.properties import ListProperty, StringProperty
import re
from kivy.lang import Builder

Builder.load_string('''
<Intro>:
    BoxLayout:
        Button:
            text: 'Press to go to SecondScreen'
            font_size: '20px'
            on_release: root.manager.current = 'SecondScreen'
<SecondScreen>:
    ComboLayout:
        Label:
            text: "working?"
            font_size: '20px'
        ComboEdit:
            size_hint: .5, .5
            pos_hint: {'center':(.5, .5)}
            font_size: '100px'
            multiline: False
''')

class ComboEdit(TextInput):
    options = ListProperty([])

    def __init__(self, **kw):
        super(ComboEdit, self).__init__(**kw)
        self.ddn = DropDown()
        self.ddn.bind(on_select=self.on_select)

    def on_options(self, instance, value):

        for option in value:
            but = Button(text=option,
                         size_hint_y=None,
                         height='36sp',
                         on_release=lambda btn: self.ddn.select(btn.text))
            self.ddn.add_widget(but)

    def on_select(self, instance, value):
        self.text = value

    def on_text(self, instance, value):

        self.options = [str(i) for i in range(0,8)]
        if not self.get_root_window():
            return # do proceed if I'm not displayed <=> If have no parent
        self.ddn.open(self)


class ComboLayout(BoxLayout):
    pass

class Intro(Screen):
    pass

class SecondScreen(Screen):
    pass

class BugDemoApp(App):
    def build(self):
        sm = ScreenManager()
        sm.add_widget(Intro(name='Intro'))
        sm.add_widget(SecondScreen(name='SecondScreen'))
        return sm

if __name__ == '__main__':
    BugDemoApp().run()
Kivy Using a ScreenManager from kv file

Kivy Using a ScreenManager from kv file


By : Sean Moran
Date : March 29 2020, 07:55 AM
hope this fix your issue The answer was using a builder to build the kv file. Knew it was something simple. File below;
main.py
code :
#!/usr/bin/kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.properties import ObjectProperty


class MenuScreen(Screen):
    pass

class NewGameScreen(Screen):
    pass

class LoadGameScreen(Screen):
    pass

class ScreenManager(ScreenManager):
    pass

buildKV = Builder.load_file("ASCIILife.kv")

class ASCIILifeApp(App):
    def build(self):
        return buildKV

if __name__ == "__main__":
    ASCIILifeApp().run()
Kivy ScreenManager Errors

Kivy ScreenManager Errors


By : Vernes Pendić
Date : March 29 2020, 07:55 AM
like below fixes the issue I'm a beginner with kivy language. I'm writing an app but I have some difficulties. My app is going to consist of a few screens so I decided to use the ScreenManager but each time I'm trying to launch the .py I get an error and this makes the python not responding. I have saved both the .py file and the .kv file in the same folder. , The problem is in the line:
code :
presentation = Builder.load_file(Aladdin.kv)
presentation = Builder.load_file("Aladdin.kv")
Problems with Kivy ScreenManager (ScreenManager.current trouble)

Problems with Kivy ScreenManager (ScreenManager.current trouble)


By : Jack p-b
Date : March 29 2020, 07:55 AM
this one helps.
The Manager in your kv code is actually a different manager than the one in your keycheck function (you have instantiated a new object of your Manager class). Try using self.manager and self.manager.current = "whatever" in your keycheck function instead of mgr = Manager(). The manager attribute of a Screen should refer to it's ScreenManager. kivy.org/doc/stable/api-kivy.uix.screenmanager.html
kivy.uix.screenmanager.ScreenManagerException: ScreenManager accepts only Screen widget

kivy.uix.screenmanager.ScreenManagerException: ScreenManager accepts only Screen widget


By : user3691394
Date : March 29 2020, 07:55 AM
will help you Your code has the following problems:
ScreenManager expects Screen type objects, does not wait for the Screen class. A name must be set for each screen and that name must be passed to current. The Image must be placed inside the screen through a layout. The animation must be started in the on_enter method that is executed when the screen is displayed. The build method of the App must return a widget. If you want 2 animations sequentially then you must use the "+" operator.
code :
import os

from kivy.app import App

from kivy.uix.image import Image
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen

from kivy.animation import Animation

current_dir = os.path.dirname(os.path.realpath(__file__))


class ScreenOne(Screen):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.img = Image(source=os.path.join(current_dir, "opencityicon.png"))
        box_layout = BoxLayout()
        self.add_widget(box_layout)
        box_layout.add_widget(self.img)

    def on_enter(self):
        self.img.opacity = 0
        animation = Animation(duration=4, opacity=1) + Animation(duration=4, opacity=0)
        animation.start(self.img)


sm = ScreenManager()
sm.add_widget(ScreenOne(name="screen_one"))
sm.current = "screen_one"


class Arge(App):
    def build(self):
        return sm


if __name__ == "__main__":
    Arge().run()
Related Posts Related Posts :
  • Save and Retrieve location inside JPEG image
  • Intent share is not able to attach image
  • Search specific nearby places using google places api web services for android
  • How to update app?
  • Is It possible to develop app with react native and make changes in android studio?
  • How to create Motion Splash Screen in Android?
  • Build Gradle Android studio Build Slow
  • Using Android DownloadManager,how do i get file name?
  • Android - How to Load More then 20mb Image in Imageview
  • Notification is not cancelled after calling notification.cancel
  • How to implement the smart-crop feature
  • Null Pointer exception on reading SMS stored in SIM in Android
  • remove google text from google maps in android
  • Image captured from camera not displaying in imageview android
  • Dynamic MpAndroidChart Not Working
  • Yandex Maps return 403 Forbidden using retrofit
  • how set selected spinner item in android studio?
  • Does Picasso library for Android handle image loading while network connectivity is off?
  • colorAccent in Holo Theme
  • Android: animation on layout after button clicked for minimum SDK version of 14
  • Are static variable truly "global" (system-wide) in Android?
  • How to create android snackbar with custom layout
  • Animate a car(Marker) along a path in google map android
  • Default to "compass" (gyroscope) mode when viewing a photosphere
  • Gradle - finished with non-zero exit value 1
  • Android Studio 2.0 Application crash on unmodified Application class
  • Android Studio cursor display error
  • Creating Dagger 2 component to be shared between src/test and src/androidTest
  • Android losing state when screen is OFF and ON again
  • Android Notification.Builder addAction PendingIntent Fragment
  • Use another button instead of back button
  • Android Studio Send string over socket after taking a picture [Google Glass]
  • Realm `access from incorrect thread` error when using shared code between IntentService and AsyncTask (Android)
  • osmdroid plotting current location offline
  • GifAnimationDrawable(Gif file) not playing in ListView
  • Controlling emission of Observable items in unit tests
  • android: Log in Button
  • Gradle github and facebook dependencies can't resolve
  • How can you animate a view back and forth between two states on Android, while supporting backpressure?
  • $(LOCAL_PATH) not returning the path to current directory correctly
  • Error:Cause: com.android.sdklib.repository.FullRevision
  • How to get an offset in RecyclerView ItemDecorator
  • Android toolbar home button not showing
  • TextView keeps popping up
  • Toolbar overlaps below status bar
  • Inflated view not updating
  • Errors of the Manifest
  • How to perform the same operation on several elements in array in doInBackground()
  • see error when use getSupportActionBar().setDisplayHomeAsUpEnabled(true)
  • What the heck is going on with this animation?
  • How to set the color of the counter on a TextInputLayout?
  • Cannot resolve symbol 'GeoJsonLayer '
  • Font file not loading on Libgdx Android
  • Simulate GCM push notifications on Android
  • Google maps provider, Wifi, 3g and GPS
  • Textview animation error
  • I want my FAB to stay at the bottom of the screen
  • How to attach multiple Images with a note taking app in android?
  • How to share xml layout using Intent.ACTION_SEND
  • Is there a default selector for the RecyclerView
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co