dropdown list is not working

72 views
Skip to first unread message

shrikant tyagi

unread,
Jan 30, 2021, 6:59:57 AM1/30/21
to kivy-...@googlegroups.com
i used this simple code.
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.base import runTouchApp

# create a dropdown with 10 buttons
dropdown = DropDown()
for index in range(10):
    # When adding widgets, we need to specify the height manually
    # (disabling the size_hint_y) so the dropdown can calculate
    # the area it needs.

    btn = Button(text='Value %d' % index, size_hint_y=None, height=44)

    # for each button, attach a callback that will call the select() method
    # on the dropdown. We'll pass the text of the button as the data of the
    # selection.
    btn.bind(on_release=lambda btn: dropdown.select(btn.text))

    # then add the button inside the dropdown
    dropdown.add_widget(btn)

# create a big main button
mainbutton = Button(text='Hello', size_hint=(None, None))

# show the dropdown menu when the main button is released
# note: all the bind() calls pass the instance of the caller (here, the
# mainbutton instance) as the first argument of the callback (here,
# dropdown.open.).
mainbutton.bind(on_release=dropdown.open)

# one last thing, listen for the selection in the dropdown list and
# assign the data to the button text.
dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, 'text', x))

runTouchApp(mainbutton)
but dropdown does not hide after click on list item or outside of list
always display list.
Please help.
image.png



Elliot Garbus

unread,
Jan 30, 2021, 10:21:21 AM1/30/21
to kivy-...@googlegroups.com

It works fine for me on Win10.  What platform are you on?

If you want a simple drop down use Spinner.

 

Here is an example using a DropDown in kv:

 

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ListProperty

kv =
"""
<ThreeButtons>:
    size_hint_y: None
    height: '48dp'
    Button:
        text: root.texts[0]
        on_release: root.parent.parent.select(self.text)
    Button:
        text: root.texts[1]
        on_release: root.parent.parent.select(self.text)
    Button:
        text: root.texts[2]
        on_release: root.parent.parent.select(self.text)


BoxLayout:
    orientation: 'vertical'
    Button:
        id: btn
        text: 'Press'
        on_release: dropdown.open(self)
        on_kv_post: dropdown.dismiss()
        size_hint_y: None
        height: '48dp'

    DropDown:
        id: dropdown
        on_select:
            btn.text = str(args[1])
            print(args)
        Button:
            text: 'First Item'
            size_hint_y: None
            height: '48dp'
            on_release: dropdown.select('First Item')
        ThreeButtons:
            texts: '1', '2', '3'
        ThreeButtons:
            texts: '4', '5', '6'
        ThreeButtons:
            texts: '7', '8', '8'
           
    Label:
        text: 'This is a DropDown Test'
"""


class ThreeButtons(BoxLayout):
    texts = ListProperty([
'0', '0', '0'])


class DDApp(App):
   
def build(self):
       
return Builder.load_string(kv)


DDApp().run()
 
 
 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAJaKc%2B2Sguce%2BCNbCtozDTjTGNH%3DShDAtUbeho-6247_9D5JTQ%40mail.gmail.com.

 

shrikant tyagi

unread,
Jan 30, 2021, 11:04:00 PM1/30/21
to kivy-...@googlegroups.com
Hi ,

i am using window 10 but still it did not auto dismiss drop down list .

image.png

when selected outside of the widget it does not auto dismiss.
everytime display this screen.
can we not create HTML type dropdown list?




Elliot Garbus

unread,
Jan 31, 2021, 12:37:25 AM1/31/21
to kivy-...@googlegroups.com
I suspect you have a problem with your installation. I recommend going to kivy.org and following the directions to install kivy 2.0.0 in a venv. 

Sent from my iPhone

On Jan 30, 2021, at 9:03 PM, shrikant tyagi <shrikan...@gmail.com> wrote:


Hi ,

i am using window 10 but still it did not auto dismiss drop down list .

<79F3F1F8F2204A4A91FDC5F79EFCE6CD.png>
 
 
 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAJaKc%2B2Sguce%2BCNbCtozDTjTGNH%3DShDAtUbeho-6247_9D5JTQ%40mail.gmail.com.

 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/6015796d.1c69fb81.764ad.ff22SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

shrikant tyagi

unread,
Jan 31, 2021, 1:09:19 AM1/31/21
to kivy-...@googlegroups.com
i also think, may be this install issue , i agin install and run then it again give same issue. 
image.png

Elliot Garbus

unread,
Jan 31, 2021, 9:45:02 AM1/31/21
to kivy-...@googlegroups.com

I suggest updating your graphics drivers: https://www.intel.com/content/www/us/en/support/intel-driver-support-assistant.html

 

 

FYI: Here is my log:

[INFO   ] [Logger      ] Record log in C:\Users\ellio\.kivy\logs\kivy_21-01-31_4.txt

[INFO   ] [deps        ] Successfully imported "kivy_deps.gstreamer" 0.3.1

[INFO   ] [deps        ] Successfully imported "kivy_deps.angle" 0.3.0

[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.3.0

[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.3.1

[INFO   ] [Kivy        ] v2.0.0

[INFO   ] [Kivy        ] Installed at "C:\Users\ellio\kivy_venv200\lib\site-packages\kivy\__init__.py"

[INFO   ] [Python      ] v3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]

[INFO   ] [Python      ] Interpreter at "C:\Users\ellio\kivy_venv200\Scripts\python.exe"

[INFO   ] [Factory     ] 186 symbols loaded

[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)

[INFO   ] [Text        ] Provider: sdl2

[INFO   ] [Window      ] Provider: sdl2

[INFO   ] [GL          ] Using the "OpenGL" graphics system

[INFO   ] [GL          ] GLEW initialization succeeded

[INFO   ] [GL          ] Backend used <glew>

[INFO   ] [GL          ] OpenGL version <b'4.6.0 - Build 27.20.100.9168'>

[INFO   ] [GL          ] OpenGL vendor <b'Intel'>

[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) UHD Graphics 620'>

[INFO   ] [GL          ] OpenGL parsed version: 4, 6

[INFO   ] [GL          ] Shading version <b'4.60 - Build 27.20.100.9168'>

[INFO   ] [GL          ] Texture max size <16384>

[INFO   ] [GL          ] Texture max units <32>

[INFO   ] [Window      ] auto add sdl2 input provider

[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked

[INFO   ] [GL          ] NPOT texture support is available

[INFO   ] [Base        ] Start application main loop

[INFO   ] [Base        ] Leaving application in progress...

 

From: shrikant tyagi
Sent: Saturday, January 30, 2021 11:09 PM
To: kivy-...@googlegroups.com
Subject: Re: [kivy-users] dropdown list is not working

 

i also think, may be this install issue , i agin install and run then it again give same issue. 

 

 

On Sun, Jan 31, 2021 at 11:07 AM Elliot Garbus <elli...@cox.net> wrote:

shrikant tyagi

unread,
Jan 31, 2021, 11:12:27 PM1/31/21
to kivy-...@googlegroups.com
Hi,

now i install python 3.9 and again install kivy then look at some differences.

when select list item as per old issue , list is not dismiss,

image.png

but when I maximize the window then it auto dismisses.
image.png
.
again we change and again minimize and maximise then it auto dismiss. 

Regards,
Shrikant Tyagi

Reply all
Reply to author
Forward
0 new messages